PHP Learning Tour 2

Source: Internet
Author: User
Computer language learning is important is the practice process, if only to see, will feel very simple but to you really write a piece of code when you will find that you learn is God horse things ah! So learn the language to constantly knock knock code!

Today's study is the initial function of PHP,

1. define function

The function is to define constants

The basic syntax is define (string constant_name,mixed value,case_sentsitive=true)

A small piece of code for the exercise is:

Define ("changliangming", "How is you\n");//The constant defined is changliangming

echo changliangming. "
";//output How is You

echo changliangming. "
";//because there is no definition so the output is changliangming, because PHP is sensitive to case, so the output here is changliangming

Define ("Zhi", "I am fine\n", true);//define constant is Zhi, where true is set case insensitive

echo Zhi. "
";//The output here is Iam fine

echo Zhi. "
";//The output here is I am fine

Define ("Dazhi", "50/n");

echo dazhi;//The output here is 50.

ECHO constant ("Dazhi"). "
";//The output here is also 50,constant is used to return the value of the constant

echo (Defined ("Hanshu")). "
";//undefined so output blank line

Define ("Hanshu", "Yegehanshu");//define constants, constants named Hanshu

echo (Defined ("Hanshu")). "
";//If the definition is positive then return the 1,defined function name is used to check whether the function name has been defined

?>

Note: In general, PHP is more sensitive to the case of letters, because PHP can be nested with HTML so that HTML tags are directly written in the middle of the PHP function,
Line breaks in the middle of HTML, \ n is an escape character, and is also a newline

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