Case sensitive problem collation for PHP

Source: Internet
Author: User

Turn from: http://www.jb51.net/article/29306.htm

PHP for case sensitive problem processing is messy, write code may occasionally problem, so here is summed up. But I am not encouraging everyone to use these rules. We recommend that you always adhere to the "case sensitive", follow the Uniform Code specifications.
First, case sensitive
1. Variable names are case-sensitive
All variables are case-sensitive, including ordinary variables as well as $_get, $_post, $_request, $_cookie, $_session, $GLOBALS, $_server, $_files, $_env, etc.
Copy code code as follows:
<?php
$ABC = ' ABCD ';
Echo $abc; Output ' ABCD '
Echo $aBc; No output
Echo $ABC; No output

2. Constant names are case-sensitive by default, and are usually written as uppercase
(but could not find a way to change this default configuration item, solve)
Copy code code as follows:
1 <?php
Define ("ABC", "Hello World");
Echo ABC; Output Hello World
ECHO ABC; Output ABC

3. PHP.ini configuration item directives are case-sensitive
such as File_uploads = 1 cannot be written file_uploads = 1
Second, not sensitive to case
4. Function name, method name, class name is not case-sensitive, but it is recommended to use the same name as the definition
Copy code code as follows:
<?php
Function Show () {
echo "Hello World";
}
Show (); Output Hello World recommended notation
Show (); Output Hello World

Copy code code as follows:
<?php
Class cls{
static function func () {
echo "Hello World";
}
}
Cls::func (); Output Hello World

5. Magic constant case-insensitive, recommended uppercase
Include: __line__, __file__, __dir__, __function__, __class__, __method__, __namespace__.
Copy code code as follows:
<?php
Echo __line__; Output 2
Echo __line__; Output 3

6. NULL, TRUE, false is case-insensitive
Copy code code as follows:
<?php
$a = null;
$b = NULL;
$c = true;
$d = TRUE;
$e = false;
$f = FALSE;
Var_dump ($a = = $b); Output Boolean True
Var_dump ($c = = $d); Output Boolean True
Var_dump ($e = = $f); Output Boolean True

7. Type casts, case-insensitive, including:
* (int), (integer) – Convert to integral type
* (BOOL), (Boolean) – Convert to Boolean
* (float), (double), (real)-Convert to floating-point
* (String)-Convert to String
* (Array)-Convert array
* (object)-Convert to Object
Copy code code as follows:
<?php
$a = 1;
Var_dump ($a); Output int 1
$b = (STRING) $a;
Var_dump ($b); Output string ' 1 ' (length=1)
$c = (string) $a;
Var_dump ($c); Output string ' 1 ' (length=1)

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.