Php case sensitive rules

Source: Internet
Author: User
PHP is not case sensitive. We recommend that you always stick to "Case sensitivity ". Note that classes and functions are case-insensitive. However, even if you are negligent, the interpreter will catch this error during debugging. I. Case sensitivity 1. Variable names are case sensitive 2. Constant names are case sensitive by default

PHP is not case sensitive. We recommend that you always stick to "Case sensitivity ". Note that classes and functions are case-insensitive. However, even if you are negligent, the interpreter will catch this error during debugging. I. Case sensitivity 1. Variable names are case sensitive 2. Constant names are case sensitive by default

PHP is not case sensitive. We recommend that you always stick to "Case sensitivity ". Note that classes and functions are case-insensitive. However, even if you are negligent, the interpreter will catch this error during debugging.
It is summarized as follows:
I. Case Sensitive
1. Variable names are case sensitive
2. By default, constant names are case sensitive and generally written in uppercase.
3. phpini configuration item commands are case sensitive
Ii. Case Insensitive
1. The function name method name class name is case-insensitive, but the same name is recommended for definition.
2. The magic constants are case-insensitive. uppercase is recommended.
3. NULL, TRUE, and FALSE are case insensitive.
4. Type forced conversion is case insensitive

I. Case sensitivity
1. Variable names are case sensitive
All variables are case sensitive, including common variables and $ _ GET, $ _ POST, $ _ REQUEST, $ _ COOKIE, $ _ SESSION, $ GLOBALS, $ _ SERVER, $ _ FILES, $ _ ENV, etc;

$ Abc = 'abc'; echo $ abc; // output 'abc' echo $ aBc; // No output echo $ ABC; // No output

2. Constant names are case-sensitive by default and are generally written in uppercase (except for magic constants)

Define ("ABC", "Hello World"); echo ABC; // output Hello Worldecho abc; // output abc

3. The php. ini configuration item command is case sensitive.
For example, file_uploads = 1 cannot be written as File_uploads = 1

Ii. Case Insensitive
1. The function name, method name, and class name are case-insensitive, but the same name as the class name is recommended.

Function show () {echo "Hello World" ;}show (); // output Hello World Recommended syntax show (); // output Hello Worldclass cls {static function func () {echo "hello world" ;}} Cls: FunC (); // output hello world

2. Magic constants are case-insensitive and should be capitalized.
Including: __line _, _ FILE _, _ DIR _, _ FUNCTION _, _ CLASS _, _ METHOD _, and _ NAMESPACE __.

Echo _ line __; // output 2 echo _ LINE __; // output 3

3. NULL, TRUE, and FALSE are case insensitive.

$ A = null; $ B = NULL; $ c = true; $ d = TRUE; $ e = false; $ f = FALSE; var_dump ($ a = $ B ); // Output boolean truevar_dump ($ c = $ d); // Output boolean truevar_dump ($ e = $ f); // Output boolean true

4. Type forced conversion, case insensitive
Including (int), (integer)-convert to integer
(Bool), (boolean)-convert to boolean
(Float), (double), (real)-convert to floating point type
(String)-convert to string
(Array)-convert to an array
(Object)-convert to object

Print_r (INT) "23AA"); // output 23print_r (int) "23AA"); // output 23

Original article address: php case sensitive rules, thanks to the original author for sharing.

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.