<?PHP print "PHP Tutorial"; //PHP Tutorial print 'PHP Tutorial'; //PHP Tutorial $a="Joni"; print "$a PHP Tutorial"; //Joni PHP Tutorial print '$a PHP Tutorial'; //$a PHP Tutorial ?>
Special characters include double quote, single quote should be escaped using
<?PHP print "John's daughter"; //John's daughter print 'John\'s daughter'; //John's daughter print 'John"s daughter'; //John"s daughter print "John\"s daughter"; //John"s daughter $arr = array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"); for($i=1;$i<=count($arr);$i++) { print $i . " is: " . $arr[$i-1] . "."; } 1 is: Monday. 2 is: Tuesday. 3 is: Wednesday. 4 is: Thursday. 5 is: Friday. 6 is: Saturday. 7 is: Sunday. ?>
<?PHP $a="4"; print_r($a); //4 $b="This is a string"; print_r($b); //This is a string $arr = array("Monday","Tuesday","Wednesday","Thusday","Friday","Saturday","Sunday"); print_r($arr); //Array ( [0] => Monday [1] => Tuesday [2] => Wednesday [3] => Thusday [4] => Friday [5] => Saturday [6] => Sunday ) unset($arr[3]); print_r($arr); //Array ( [0] => Monday [1] => Tuesday [2] => Wednesday [4] => Friday [5] => Saturday [6] => Sunday ) ?>
<?PHP $a=33400; printf("%e",$a); //3.340000e+4 printf("%b",$a); //1000001001111000 printf("%b in scientific format is %e",$a,$a); //33400 in scientific fomrat is 3.340000e+4 $s=sprintf("%b in scientific format is %e",$a,$a); echo "$s"; //33400 in scientific fomrat is 3.340000e+4 ?>