PHP Learning Note 1-constants, functions, PHP learning Note 1-constants
Constants: Use const (PHP5) Declaration, can only be assigned once, PHP5 the following versions use define;
1
PHP2const the_value = 100; // only const in PHP5 3 Echo The_value; 4 5 Define (' The_value ', 200); // older versions below PHP5 can be used define 6 Echo The_value;
Function: A code block that wraps a lot of functions;
Pros: Easy to invoke elsewhere
1 Php 2 3 function tracehellophp () { 4 Echo' Hello php! ' ; 5 Echo'
' ; 6 Echo' Hello world! ' ; 7 Echo'
' ; 8 } 9 tracehellophp (); Ten One // another way to perform a function A $func= ' tracehellophp '; // Pass the function as a parameter, e.g. callback method - $func (); - the // incoming parameters of a function--single incoming parameter - functionSayhelloto ( $name ){ - Echo' Hello '. $name.'
' ; - } +Sayhelloto (' Vito ' ); - + // incoming parameters of a function--Multiple incoming parameters A functionTracenum ( $a, $b ){ at // echo ' A = '. $a. ', B = '. $b. '
'; - Echo"A = $a, B = $b"; // a simpler way to do it - } -Tracenum (2,3 ); - - functionAdd $a, $b ){ in return $a+ $b; // return value - } to EchoAdd (10,2); View Code
http://www.bkjia.com/PHPjc/1022594.html www.bkjia.com true http://www.bkjia.com/PHPjc/1022594.html techarticle PHP Learning Note 1-constants, functions, PHP learning Note 1-Constant constants: Use const (PHP5) Declaration, can only be assigned once, PHP5 the following versions using Define; 1? PHP 2 const the_value ...