. n"); for($currentDate = date("U"); //Define the $currentDate time format date("l", $currentDate) != "Monday"; //Judge whether it is current The system time is Monday. print("
" . date ("l", $currentDate) . "n"); } print("
n"); ?>
Simple call of function :
Simple function
< function printBold ($inputText) //Define function printBold() { "This business No aggravation! n"); . ("This line is not emphasized! n"); //Print the string directly ?>
Function with return value
Function with return value
function makeBold ($inputText) //Define the function makeBold() function >"; return($ boldedText); //Return variable $boldedText } print("This line is not bold!!! n"); //Print the string directly print(makeBold("This line is bold!!! ")." & Lt; br & gt; n "); // Call the function makebold () function Print (" This line is not worse!!!! n"); //Print the string directly ?>
Function with default parameters
< HEAD> "black") . This is the word of black color! "); // call the function function Print (" & lt; br & gt; & lt; br & gt;"," Blue "); // Call the function function Print (" & lt; br & gt; n "); Algorithm to determine whether it is an integer
Judge integer
Function checkInteger($Number) {
elseif($Number * For a negative number, */ /* You can analyze its absolute value*/
} * According to relevant mathematical definitions */ " ;BR>n"); print("7 is an integer? " . checkInteger(7) . " n"); print(" What about 3.5? " . checkInteger(3.5) . " n"); print("What about -5?" . checkInteger(-5) . "< BR>n"); print("And -9.2?" . checkInteger(-9.2) . " n"); ?>
Initialize array
Initialize array
& lt;? " September", "October", "November", "December"); print(""May" in English is $monthName[5] . n");//Print the 6th element in the array ?>
Get the element in the array
Get elements in the array
$monthName = array( ) /*Define $monthName[1] to $monthName[ 12]*/ 1=>"January", "February", "March", "April", "May", "June", "July", "August", "September", " October ", "November", "December", /*Define $monthName["Jan"] to $monthName["Dec"]*/ "Jan"=>"January", "Feb"=>"February ", "Mar"=>"March", "Apr"=>"April", "May"=>"May", "Jun"=>"June", "Jul"=> ;"July", "Aug"=>"August", "Sep"=>"September", "Oct"=>"October", "Nov"=>"November", "Dec" =>"December", " /*Define $monthName["Jan"] to $monthName["Dec"]*/ "January"=>"January", "February"=>"February", "March"=>"March", "April"=>"April", "May"=>"May", "June"=>"June", "July"=>"July ", "August"=>"August", "September"=>"September", "October"=>"October", "November"=>"November", "December"=> "December" ); /*Print related elements*/ print("Month 5 is " . $monthName[5]. "< BR>n"); print("Month Aug is " . $monthName["Aug"] . " n"); print("Month June is " . $monthName["June"] . " n"); ?> BODY>
The above has introduced the 1/2 pages of several classic codes that must be collected when learning PHP, including relevant content. 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