PHP Case Sensitive problem finishing _php tutorial

Source: Internet
Author: User
Tags type casting
PHP handling of case-sensitive issues is messy, writing code may occasionally problem, so here to summarize.
But I'm not encouraging you to use these rules. We recommend that you always adhere to the "case sensitive" and follow the Uniform Code specification.
first, case sensitive
1. Variable names are case-sensitive
All variables are case-sensitive, including common variables as well as $_get, $_post, $_request, $_cookie, $_session, $GLOBALS, $_server, $_files, $_env, etc.;
Copy CodeThe code is as follows:
$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 in uppercase
(but not found can change this default configuration item, solve)
Copy CodeThe code is as follows:
1 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 as File_uploads = 1
second, the case is not sensitive
4. The function name, method name, class name are not case-sensitive, but the same name as the definition is recommended
Copy CodeThe code is as follows:
Function Show () {
echo "Hello World";
}
Show (); Output Hello World recommended notation
SHOW (); Output Hello World

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

5. Magic constants are case-insensitive, recommended capitalization
Include: __line__, __file__, __dir__, __function__, __class__, __method__, __namespace__.
Copy CodeThe code is as follows:
Echo __line__; Output 2
Echo __line__; Output 3

6. NULL, TRUE, false case insensitive
Copy CodeThe code is as follows:
$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 casting, case insensitive, including:
* (int), (integer) – Converted to integral type
* (BOOL), (Boolean) – converted to Boolean
* (float), (double), (real) – convert to floating-point type
* (String) – converted to a string
* (Array) – Convert an array
* (Object) – Convert to Object
Copy CodeThe code is as follows:
$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)

http://www.bkjia.com/PHPjc/324820.html www.bkjia.com true http://www.bkjia.com/PHPjc/324820.html techarticle PHP handling of case-sensitive issues is messy, writing code may occasionally problem, so here to summarize. But I'm not encouraging you to use these rules. Recommend everyone always adhere to the " ...

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