$str = "My name is O\'Billa?";
echo stripslashes($str);// Outputs: My name is O'Billa?
$str = "My name is O'Billa?";
echo stripslashes($str);// Outputs: My name is O\'Billa?
$str = "Vijay's next film Villu";
$str = strtoupper($str);
echo $str; // Prints VIJAY'S NEXT FILM VILLU
$str = "AJITH'S NEXT FILM AEGAN";
$str = strtoupper($str);
echo $str; // Prints ajith's next film aegan
Thursday, June 26, 2008
Wednesday, June 25, 2008
PHP String Funcitons
$txt="PHP MYSQL";
echo $txt; // Returns PHP MYSQL (Print the text)
echo strlen("My first coding in PHP"); // Returns 22 (Print the string length)
echo strpos("Hello world","l"); // Returns 2 (Print the string position)
$email = 'ashokseenivas50@gmail.com';
$domain = strstr($email, '@');
echo $domain; // prints @gmail.com
$user = strstr($email, '@', true);
echo $user; // prints ashokseenivas50
echo $txt; // Returns PHP MYSQL (Print the text)
echo strlen("My first coding in PHP"); // Returns 22 (Print the string length)
echo strpos("Hello world","l"); // Returns 2 (Print the string position)
$email = 'ashokseenivas50@gmail.com';
$domain = strstr($email, '@');
echo $domain; // prints @gmail.com
$user = strstr($email, '@', true);
echo $user; // prints ashokseenivas50
Wednesday, June 18, 2008
PHP Array Functions
Array Merge
$array1 = array("fruits" => "apple", 2, 4);
$array2 = array("a", "b", "fruits" => "orange", "shape" => "rectangle", 4);
$result = array_merge($array1, $array2);
print_r($result);
Array Combine
$a = array('a', 'b', 'c');
$b = array('d', 'e', 'f');
$c = array_combine($a, $b);
print_r($c);
Array Push
$stack = array("a", "b");
array_push($stack, "c", "d");
print_r($stack);
Array Pop
$stack = array("a", "b", "c", "d");
$fruit = array_pop($stack);
print_r($stack);
$array1 = array("fruits" => "apple", 2, 4);
$array2 = array("a", "b", "fruits" => "orange", "shape" => "rectangle", 4);
$result = array_merge($array1, $array2);
print_r($result);
Array Combine
$a = array('a', 'b', 'c');
$b = array('d', 'e', 'f');
$c = array_combine($a, $b);
print_r($c);
Array Push
$stack = array("a", "b");
array_push($stack, "c", "d");
print_r($stack);
Array Pop
$stack = array("a", "b", "c", "d");
$fruit = array_pop($stack);
print_r($stack);
Thursday, June 12, 2008
.htaccess tutorial
1) Password Protected Directory
AuthUserFile /your/directory/here/.htpasswd
AuthGroupFile /dev/null
AuthName "Secure Document"
AuthType Basic
require user username
2) Password Protectection for a file
AuthName "Restricted File"
AuthType Basic
AuthUserFile /user/home/www/directory/.htpasswd
require valid-user
3) Protecting the file types
AuthName "Restricted"
AuthType Basic
AuthUserFile /user/home/www/directory/.htpasswd
require valid-user
4) Error Documents
ErrorDocument 400 /error/badrequest.htm
ErrorDocument 401 /error/authorisereqd.htm
ErrorDocument 403 /error/forbidden.htm
ErrorDocument 404 /error/filenotfound.htm
ErrorDocument 500 /error/servererror.htm
5) Redirecting Pages
Redirect /old-directory/oldpage.htm http://domain.com/new-directory/newpage.htm
Redirect /old-directory http://domain.com/new-directory/
6) Default page
DirectoryIndex default.htm
DirectoryIndex default.htm home.cgi sadass.pl otherfile.html
7) Add types and Add handler
AddType text/html .html
AddHandler server-parsed .html
AddHandler server-parsed .htm
8) Block Users by using IP
order deny,allow
deny from 123.456.789.000
deny from .domain.com
allow from all
AuthUserFile /your/directory/here/.htpasswd
AuthGroupFile /dev/null
AuthName "Secure Document"
AuthType Basic
2) Password Protectection for a file
AuthName "Restricted File"
AuthType Basic
AuthUserFile /user/home/www/directory/.htpasswd
require valid-user
3) Protecting the file types
AuthName "Restricted"
AuthType Basic
AuthUserFile /user/home/www/directory/.htpasswd
require valid-user
4) Error Documents
ErrorDocument 401 /error/authorisereqd.htm
ErrorDocument 403 /error/forbidden.htm
ErrorDocument 404 /error/filenotfound.htm
ErrorDocument 500 /error/servererror.htm
5) Redirecting Pages
Redirect /old-directory/oldpage.htm http://domain.com/new-directory/newpage.htm
Redirect /old-directory http://domain.com/new-directory/
6) Default page
DirectoryIndex default.htm
DirectoryIndex default.htm home.cgi sadass.pl otherfile.html
7) Add types and Add handler
AddType text/html .html
AddHandler server-parsed .html
AddHandler server-parsed .htm
8) Block Users by using IP
order deny,allow
deny from 123.456.789.000
deny from .domain.com
allow from all
Monday, June 9, 2008
PHP Secure mail example
$to = 'ashokseenivas50@gmail.com' ;
$subject = 'PHP Technical Questions';
$message = '
Upload Your Resumes: PHP FAQ,
PHP interview questions,
PHP Frequently Asked Questions,
Earn More money from google,
Cricket Updates,
Cinema gossips,
Dating.
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Mary, Kelly ' . "\r\n";
$headers .= 'From: Blog Creation' . "\r\n";
$headers .= 'Cc: seenivasagaperumal@yahoo.com' . "\r\n";
$headers .= 'Bcc: seenivasagaperumal@yahoo.com' . "\r\n";
mail($to, $subject, $message, $headers);
$subject = 'PHP Technical Questions';
$message = '
Upload Your Resumes: PHP FAQ,
PHP interview questions,
PHP Frequently Asked Questions,
Earn More money from google,
Cricket Updates,
Cinema gossips,
Dating.
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Mary
$headers .= 'From: Blog Creation
$headers .= 'Cc: seenivasagaperumal@yahoo.com' . "\r\n";
$headers .= 'Bcc: seenivasagaperumal@yahoo.com' . "\r\n";
mail($to, $subject, $message, $headers);
Monday, May 26, 2008
PHP checkbox array example
if (isset($_POST['submit'])) {
$fruit = $_REQUEST["fruit"];
echo("Fruits chosen: " . count($fruit));
for ($i=0; $i<count($fruit); $i++) {
echo( ($i+1) . ") " . $fruit[$i]);
}
}
$fruit = $_REQUEST["fruit"];
echo("Fruits chosen: " . count($fruit));
for ($i=0; $i<count($fruit); $i++) {
echo( ($i+1) . ") " . $fruit[$i]);
}
}
Wednesday, May 21, 2008
PDF Generation Using PHP
PDF Generation Using PHP
$pdf=new FPDF();
$pdf->AddFont('Calligrapher','','calligra.php');
$pdf->AddPage();
$pdf->SetFont('Calligrapher','',35);
$pdf->Cell(0,10,'Enjoy new fonts with FPDF!');
$pdf->Output();
More Examples:
PDF Generation using line breaks
PDF Generation using header footer
$pdf=new FPDF();
$pdf->AddFont('Calligrapher','','calligra.php');
$pdf->AddPage();
$pdf->SetFont('Calligrapher','',35);
$pdf->Cell(0,10,'Enjoy new fonts with FPDF!');
$pdf->Output();
More Examples:
PDF Generation using line breaks
PDF Generation using header footer
Subscribe to:
Posts (Atom)