90 Web Forum PHP Basics

Source: Internet
Author: User
Tags php basics variable scope

Constant:

1. Concept
Constants are containers that store values (data) for temporary (only when our program is running)
2. Definition and use
Define (' constant name ', constant value) or define ("constant name", constant value)
Name of the constant:
1) can only contain alphanumeric underscores and must start with a letter or underscore
2) By convention constant names are always capitalized
3) Custom constants are strictly case-sensitive!
Defined () function to check if a constant is defined
3. The difference between constants and variables
1) No dollar sign ($) before constant
2) constants can only be defined with the Define () function and cannot be evaluated by an assignment statement
3) ******** constants can be defined and used anywhere without regard to the rules of variable scope
4) constants cannot be redefined or undefined once they are defined
5) The value of a constant can only be a bool,int,float,string type
4. Pre-defined constants
Predefined constants Well, that's the constant that our PHP kernel has already defined for us!

Some of the predefined constants are the beginning of a __, and these predefined constants we call it Magic constants

The code is in a different location and his value is different, so it adds magic constants.
Eight Common Magic constants
http://php.net/manual/zh/language.constants.predefined.php
Predefined constants are case-insensitive!

Define (' Constant name ', constant value); Define ("Constant name", constant value);
Example:
<? PHP $a= ' 90 web forum '; Define (' My_name ', ' 90 web forum '); Echo my_name;? >

90 Web Forum PHP Basics

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.