: This article mainly introduces PHP learning Notes 1-constants and functions. if you are interested in PHP tutorials, refer to them. Constant: the const (php5) statement can only be assigned once. define is used for versions earlier than php5;
1
Function: contains a lot of functional code blocks;
Advantage: easy to call elsewhere
1
'; 6 echo 'Hello World! '; 7 echo'
'; 8} 9 traceHelloPHP (); 1011 // Another function execution method 12 $ func = 'tracehellophp'; // The function is passed as a parameter, e.g. callback method 13 $ func (); 1415 // input parameter of the function -- single input parameter 16 function sayHelloTo ($ name) {17 echo 'hello '. $ name.'
'; 18} 19 sayHelloTo ('Vito'); 2021 // input parameters of the function -- multiple input parameters 22 function traceNum ($ a, $ B) {23 // echo 'a = '. $. ', B = '. $ B.'
'; 24 echo "a = $ a, B = $ B"; // relatively simple syntax 25} 26 traceNum (2, 3); 2728 function add ($ a, $ B) {29 return $ a + $ B; // return value 30} 31 echo add (10, 2 );
View CodeThe above introduces the PHP learning Notes 1-constant, function, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.