Are php variable names case sensitive?

王林
Release: 2023-02-26 12:46:02
Original
5177 people have browsed it

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;    //无输出
?>
Copy after login

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;
?>
Copy after login

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;];    //上面讲过,变量名区分大小写,所以无输出并报错
?>
Copy after login

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!

Related labels:
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