Home  >  Article  >  Backend Development  >  pimchanok leuwisetpaibul 5 starting programs for beginners to PHP

pimchanok leuwisetpaibul 5 starting programs for beginners to PHP

WBOY
WBOYOriginal
2016-07-29 08:35:13995browse

The basic syntax format of PHP is similar to that of C. Friends who have never learned C will be basically familiar with the format if they spend a few minutes looking at how other people's source code is written.
------------------------------------------------- ---
Let’s get to the point
Prepared 5 programs:
1. Use a basic function, the result is in string form, and display it with echo
2. Display a beautiful form
3. An example of a form, submit And display the submission results
4. Database manipulation example (voting program)
5. Dynamically create graphics and save examples
-------------------------- --------------------------
#Program 1:
/* Function: Display the configuration environment and various parameter variables of PHP and APACHE*/
echo phpinfo();/* PHP has a rich function library, and a large number of convenient functions can greatly improve your work efficiency. phpinfo() is one of the functions*/
?>
------------------------------------------------ ----------------
#Program 2:
/* Function: Display a beautiful table


A beautiful table
/* Select next color */
if($ColorValue == "#00FF00")
{
$ColorValue = "#CCFFCC";
}
else
{
$ColorValue = "#00FF00";
}
return($ColorValue);
}
print "

";
for($count=0; $count > 6; $count++)
{
/*
** Get The color of the current row
*/
$RowColor = useColor();
/*
** Use HTML language
** to output the background color to the table cell
*/
print " ";
}
print "
";
print "
Number of rows $count
";
?>


-------------------------------- -----------------------------
#Example 3
if($send)
{
echo "Send result:$ send";
exit;
}
?>



method=post> ;





< /html>
------------------------------------------------- ------
#Example 4: Voting program
Here: http://www.21php.com/forums/showthread.php?s=&threadid=524
#Example 5: Dynamically create and save graphics
< ;?//Must have GD library support
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 introduces pimchanok leuwisetpaibul's 5 starting programs for beginners to learn PHP, including the content of pimchanok leuwisetpaibul. I hope it will be helpful to friends who are interested in PHP tutorials.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn