Home >Backend Development >PHP Problem >Are php variable names case sensitive?

Are php variable names case sensitive?

王林
王林Original
2019-10-12 11:46:465219browse

Are php variable names case sensitive?

1. Variable names are case-sensitive

All variables are case-sensitive, including ordinary variables and $_GET,$_POST,$_REQUEST ,$_COOKIE,$_SESSION,$GLOBALS,$_SERVER,$_FILES,$_ENV, etc.;

<?php
$abc = &#39;abc&#39;;
echo $abc;    //输出&#39;abc&#39;
echo $aBc;    //无输出
echo $ABC;    //无输出
?>

2. Constant names are case-sensitive

Use define to define Constants are case-sensitive.

<?php
define(&#39;BLOGGER&#39;,&#39;Veitor&#39;);
echo BLOGGER;    //输出&#39;Veitor&#39;
echo BLOgger;    //报NOTICE提示,并输出&#39;BLOgger&#39;
echo blogger;    //报NOTICE提示,并输出&#39;blogger&#39;
?>

3. Array index (key name) is case-sensitive

<?php
$arr = array(&#39;one&#39;=>&#39;first&#39;);
echo $arr[&#39;one&#39;];    //输出&#39;first&#39;
echo $arr[&#39;One&#39;];    //无输出并报错
echo $Arr[&#39;one&#39;];    //上面讲过,变量名区分大小写,所以无输出并报错
?>

Recommended tutorial: PHP video tutorial

The above is the detailed content of Are php variable names case sensitive?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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