PHP's basic syntax format and C-like, did not learn C's friends spend a few minutes to see how others write the source code, the basic familiar with the format.
----------------------------------------------------
Get down to the chase.
5 programs were prepared:
1. Using a basic function, the result is a string form, shown with Echo
2. Show a nice table
3. A form example that submits and displays the results of the submission
4. Example of database manipulation (voting procedure)
5. Dynamically create graphs and save examples
----------------------------------------------------
#程序1:
/* Function: Display PHP extremely Apache configuration environment and various parameter variables */
Echo phpinfo ();/* PHP has a rich library of functions, a lot of convenient functions greatly improve your productivity. Phpinfo () is one of the functions */
?>
----------------------------------------------------
#程序2:
/* Function: Show a nice table
<title>A nice table.</title>
function Usecolor ()
{
/*
* * Please keep in mind the color tags we used last
*/
Static $ColorValue;
/* Select Next color */
if ($ColorValue = = "#00FF00")
{
$ColorValue = "#CCFFCC";
}
Else
{
$ColorValue = "#00FF00";
}
return ($ColorValue);
}
Print "
"; for ($count =0; $count > 6; $count + +) {/* * Gets the color of the current line */$RowColor = Usecolor "
"; Print " Number of rows $count |
"; } Print "
";
?>
----------------------------------------------------
#例子3
if ($send)
{
echo "Send result: $send";
Exit
}
?>
<title></title>
----------------------------------------------------
#例子4: Voting procedures
Here: http://www.21php.com/forums/showthread.php?s=&threadid=524
#例子5: Create and save graphics dynamically
Header ("Content-type:image/jpeg");
$im =imagecreate (400,30);
$black =imagecolorallocate ($im, 0,0,0);
$white =imagecolorallocate ($im, 255,255,255);
Imagettftext ($im, 20,0,10,20, $white, "C:windowsfontsraavi.ttf", "I am Kinter");
Imagejpeg ($im, "hello.jpeg");
Imagedestroy ($im);
?>
The above describes the Pimchanok Leuwisetpaibul to beginners PHP 5 starting procedures, including the Pimchanok Leuwisetpaibul aspects of the content, I hope that the PHP tutorial interested in a friend helpful.