<?php
/*
* The three faces of Π
*/
printf ("Pi is: %.2fn<br>n", M_PI);
printf ("Pi is also: %.3fn<br>n", M_PI);
printf ("Pi is also: %.4fn<br>n", M_PI);
?>
<?php
$tmp = date ("F d, h:i a"); /* ie January 3, 2:30 pm */
print $tmp;
?>
就应当改成:
<?php
print date ("F d, h:i a");
?>
又如:
<?php
// string reverse_characters(string str)
// Reverse all of the characters in a string.
function reverse_characters ($str)
{
return implode ("", array_reverse (preg_split("//", $str)));
}
?>
的可读性不强,可改成:
<?php
// string reverse_characters(string str)
// Reverse all of the characters in a string.
function reverse_characters ($str)
{
$characters = preg_split ("//", $str);
$characters = array_reverse ($characters);
return implode ("", $characters);
}
?>