PHP Learning Note 1-constants, functions, PHP learning Note 1-Constants _php Tutorial

Source: Internet
Author: User

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 ...

  • 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.