PHP Study Notes 1-constants, functions, php Study Notes 1-constant _ PHP Tutorial

Source: Internet
Author: User
PHP learning Notes 1-constant, function, php learning Notes 1-constant. PHP learning Notes 1-constant, function, php learning Notes 1-constant: use const (php5) declaration, can only be assigned once, php5 and earlier versions use define; 1? Php2constTHE_VALUE PHP Study Notes 1-constants, functions, php Study Notes 1-constants

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 (); 10 11 // Another function execution method 12 $ func = 'tracehellophp'; // use the function as a parameter for passing, e.g. callback method 13 $ func (); 14 15 // input parameter of the function -- single input parameter 16 function sayHelloTo ($ name) {17 echo 'hello '. $ name.'
'; 18} 19 sayHelloTo ('Vito'); 20 21 // input parameters of the function -- multiple input parameters 22 function traceNum ($ a, $ B) {23 // echo 'a = '. $. ', B = '. $ B.'
'; 24 echo "a = $ a, B = $ B"; // a simpler method 25} 26 traceNum (2, 3); 27 28 function add ($, $ B) {29 return $ a + $ B; // return value 30} 31 echo add (10, 2 );
View Code

Constant: the const (php5) statement can only be assigned once. define; 1? Php 2 const THE_VALUE...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.