Home > Backend Development > PHP Tutorial > Summary of the issue of whether PHP is case sensitive

Summary of the issue of whether PHP is case sensitive

WBOY
Release: 2016-07-25 08:58:10
Original
1319 people have browsed it
PHP is case sensitive for variables and constants. Class names and method names are not case-sensitive. It is not sensitive to null, false, true, etc., and is also sensitive to the configuration parameters in php.ini. This article summarizes the issues in this regard.

This article is a summary of whether PHP is case sensitive. However, it is recommended to always adhere to "case sensitivity" and follow unified coding standards. 1. Case sensitivity 1. Variable names are case-sensitive

<?php
/**
* 大小写敏感
* edit bbs.it-home.org
*/
$abc ='abcd';
echo $abc; //输出 'abcd'
echo $aBc; //无输出
echo $ABC; //无输出
?>
Copy after login

2. Constant names are case-sensitive by default and are usually written in uppercase. (But I couldn’t find a configuration item that can change this default, please solve it)

<?php
define("ABC","Hello World");
echo ABC;  //输出 HelloWorld
echo abc;  //输出abc
?>
Copy after login

3, php.ini configuration item instructions are case sensitive For example, file_uploads = 1 cannot be written as File_uploads = 1

2. Case insensitive 1. Function names, method names, and class names are not case-sensitive, but it is recommended to use the same names as when they were defined. 2. Magic constants are not case-sensitive, uppercase is recommended Includes: __LINE__, __FILE__, __DIR__, __FUNCTION__, __CLASS__, __METHOD__, __NAMESPACE__.

<?php
echo __line__;  //输出 2
echo __LINE__;  //输出 3
//by bbs.it-home.org
?>
Copy after login

3. NULL, TRUE, and FALSE are not case-sensitive. The php function var_dump is used below.

<?php
$a =null;
$b =NULL;
  
$c =true;
$d =TRUE;
  
$e =false;
$f =FALSE;
  
var_dump($a ==$b);//输出 boolean true
var_dump($c ==$d);//输出 boolean true
var_dump($e ==$f);//输出 boolean true
//by bbs.it-home.org
?>
Copy after login


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template