PHP大小写是否敏感问题 - zzwind's Blog

PHP大小写是否敏感问题

zzwind posted @ 2010年7月16日 18:09 in php , 2771 阅读

 

一、大小写敏感

1. 变量名区分大小写

所有变量均区分大小写,包括普通变量以及$_GET,$_POST,$_REQUEST,$_COOKIE,$_SESSION,$GLOBALS,$_SERVER,$_FILES,$_ENV等;

1 <?php
2 $abc 'abcd';
3 echo $abc//输出 'abcd'
4 echo $aBc//无输出
5 echo $ABC//无输出

2. 常量名默认区分大小写,通常都写为大写

(但没找到能改变这个默认的配置项,求解)

1 <?php
2 define("ABC","Hello World");
3 echo ABC;   //输出 Hello World
4 echo abc;   //输出 abc

3. php.ini配置项指令区分大小写

如 file_uploads = 1 不能写成 File_uploads = 1

二、大小写不敏感

1. 函数名、方法名、类名 不区分大小写,但推荐使用与定义时相同的名字

1 <?php
2 function show(){
3 echo "Hello World";
4 }
5 show(); //输出 Hello World    推荐写法
6 SHOW(); //输出 Hello World
1 <?php
2 class cls{
3 static function func(){
4 echo "hello world";
5 }
6 }
7  
8 Cls::FunC();  //输出hello world

2. 魔术常量不区分大小写,推荐大写

包括:__LINE__、__FILE__、__DIR__、__FUNCTION__、__CLASS__、__METHOD__、__NAMESPACE__。

1 <?php
2 echo __line__;  //输出 2
3 echo __LINE__;  //输出 3

3. NULL、TRUE、FALSE不区分大小写

01 <?php
02 $a = null;
03 $b = NULL;
04  
05 $c = true;
06 $d = TRUE;
07  
08 $e = false;
09 $f = FALSE;
10  
11 var_dump($a == $b); //输出 boolean true
12 var_dump($c == $d); //输出 boolean true
13 var_dump($e == $f); //输出 boolean true

4.类型强制转换,不区分大小写

包括

  • (int),(integer) – 转换成整型
  • (bool),(boolean) – 转换成布尔型
  • (float),(double),(real) – 转换成浮点型
  • (string) – 转换成字符串
  • (array) – 转换成数组
  • (object) – 转换成对象
1 <?php
2 $a=1;
3 var_dump($a);  //输出 int 1
4  
5 $b=(STRING)$a;
6 var_dump($b);  //输出string '1' (length=1)
7  
8 $c=(string)$a;
9 var_dump($c);  //输出string '1' (length=1)

 

Avatar_small
JKBOSE Model Paper C 说:
2022年9月08日 19:23

JKBOSE Model Paper 2023 Class 6 Pdf Download with Answers for English Medium, Hindi Medium, Urdu Medium & Students for Small Answers, Long Answer, Very Long Answer Questions, and Essay Type Questions to Term1 & Term2 Exams at official website. JKBOSE Model Paper Class 6 New Exam Scheme or Question Pattern for Sammittive Assignment Exams (SA1 & SA2): Very Long Answer (VLA), Long Answer (LA), Small Answer (SA), Very Small Answer (VSA), Single Answer, Multiple Choice and etc.

Avatar_small
pavzi.com 说:
2023年4月16日 15:25

We provide you with the finest web content on each and every topic possible with help of the editorial and content team.Pavzi Post is a startup by passionate webmasters and bloggers who have a passion to provide engaging content which is accurate, interesting and worthy to read. We are more like a web community where you can pavzi.com find different information, resources, and topics on day-to-day incidents or news.

Avatar_small
civaget 说:
2023年12月14日 04:06

My revenue skyrocketed thanks to 백링크하이's expert services. A game-changer for my business.

Avatar_small
civaget 说:
2023年12月17日 19:35

제주오피 offers a fantastic array of choices. From pricing to service details, it's a one-stop-shop for officetel massages.

Avatar_small
civaget 说:
2023年12月19日 21:01

강남오피 sets the standard for relaxation with its range of services, from massages to skincare. With 70+ locations, it's a true Gangnam favorite.

Avatar_small
civaget 说:
2023年12月19日 23:14

스포츠중계's live scores and highlights keep me updated.

Avatar_small
civaget 说:
2023年12月22日 03:51

When it comes to 토토 gaming, trust 토토 Match to provide a selection of secure and enjoyable options, ensuring your peace of mind while you bet online.

Avatar_small
civaget 说:
2023年12月30日 17:39

I've been looking for ways to reduce stress and enhance my life. 휴식 and OPGuide could be the answer.

Avatar_small
civaget 说:
2024年1月15日 15:43

Some truly interesting points you have written. Aided me a lot, just what I was looking for : D. คืนยอดเสีย ทุกวัน

Avatar_small
jnanabhumiap.in 说:
2024年1月18日 18:59

JNANABHUMI AP offers the most recent information on education. The primary idea or goal of this website has been to offer comprehensive resources with information on any subject that can be accessed online. To make sure that every reader finds out what they should know about the subject they are interested in and jnanabhumiap.in links to our content.Jnanabhumi AP is a startup founded by enthusiastic bloggers and webmasters who are driven to produce interesting, factual, and well-written content. We are similar to an online community where you can find a variety of resources, information, and topics about newsworthy events or daily occurrences.

Avatar_small
SEO 说:
2024年1月23日 16:19

Thanks so much for another post. I be able to get that kind of information information. friend, and exactly. The Presidential Family

Avatar_small
SEO 说:
2024年2月01日 13:10

Hello, i just planned to drop that you a line to say that we thoroughly enjoyed this particular post from yours, I have subscribed for your RSS feed and have absolutely skimmed several of your articles or blog posts before but this blog really endured out in my situation. lpb piso wifi 10.0.0.1 pause time login

Avatar_small
how to change group 说:
2024年2月01日 18:30

Substantially, this publish is really the sweetest on this notable theme. I harmonise along with your conclusions and will thirstily seem ahead in your incoming updates. Stating thanks will not likely just be ample, for that phenomenal clarity with your writing. I will right grab your rss feed to stay informed of any updates. Admirable operate and considerably accomplishment with your enterprise dealings! Please excuse my poor English as it’s not my very first tongue.

Avatar_small
SEO 说:
2024年2月04日 15:01

I believe that a simple and unassuming manner of life is best for everyone, best both for the body and the mind. Büyükçekmece Escort

Avatar_small
biggest loser smart 说:
2024年2月05日 15:15

Excellent blog here! Also your web site loads up fast! What host are you using? Can I get your affiliate link to your host? I wish my website loaded up as quickly as yours lol

Avatar_small
nicole 说:
2024年2月07日 14:28

Great post however , I was wanting to know if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit further. Bless you! murahqq

Avatar_small
seo 说:
2024年2月10日 17:23

I was curious if you ever considered changing the page layout of your blog? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or two pictures. Maybe you could space it out better? The exodus Effect Book

Avatar_small
seo 说:
2024年2月11日 12:24

Immigration Lawyers… [...]the time to read or visit the content or sites we have linked to below the[...]… 유흥용어

Avatar_small
seo 说:
2024年2月12日 12:32

Not often do I encounter a weblog that is both educated and entertaining, and let me tell you, you may have hit the nail on the head. Your concept is excellent; the issue is something that not sufficient individuals are speaking intelligently about. I am very happy that I stumbled across this in my quest for something relating to this. リアルドール

Avatar_small
seo 说:
2024年2月12日 16:33

After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think. Blox Fruits codes

Avatar_small
seo 说:
2024年2月12日 18:25

I am glad to be a visitor of this consummate web site! , appreciate it for this rare info ! . Nickel battery tab production

Avatar_small
seo 说:
2024年2月15日 16:38

You are a very persuasive writer. I can see this in your article. You have a way of writing compelling information that sparks much interest. خرید استئارات منیزیم؛ فروش قیمت منیزیم استئارات

Avatar_small
seo 说:
2024年2月16日 22:13

Fantastic article. Cool. bestoto88

Avatar_small
seo 说:
2024年2月22日 03:09

This is such a great post, and was thinking much the same myself. Another great update. 먹튀사이트

Avatar_small
seo 说:
2024年2月25日 12:22 Found this on MSN and I’m happy I did. Well written article. đăng ký Xanh SM Bike

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee