在访问PHP类中的成员变量或方法时,如果被引用的变量或者方法被声明成const(定义常量)或者static(声明静态),那么就必须使用操作符::,反之如果被引用的变量或者方法没有被声明成const或者static,那么就必须使用操作符-。 另外,如果从类的内部访问const变
在访问PHP类中的成员变量或方法时,如果被引用的变量或者方法被声明成const(定义常量)或者static(声明静态),那么就必须使用操作符::,反之如果被引用的变量或者方法没有被声明成const或者static,那么就必须使用操作符->。
另外,如果从类的内部访问const变量或者static变量或者static方法,那么就必须使用自引用的self,反之如果从类的内部访问不为const或者static变量或者方法,那么就必须使用自引用的$this
1:很有疑问,在强类型语言中,变量和函数以及类名都是区分大小写的,js是严格区分大小写的,但是PHP有点不一样:
$a="x123";
$A="y123";
echo $a."\n";
echo $A;
?>
输出的结果大家都是知道的;
2:
class registry{
protected $x='you';
function test(){
return $this->x;
}
}
$c= new Registry();
$c->TEST();
这样的写法在类中是 不区分大小写的。
2:
有时用var_dump调试数组输出的时候,后面层级数组显示不出来,省略号了,下面是在php.ini的xdebug节点下加入的,重启服务,具体的字段意思就根据需要来配置吧。
xdebug.var_display_max_children=128
xdebug.var_display_max_data=1024
xdebug.var_display_max_depth=15
3:
$str="method";
echo $str{0}; //这里输出的是m
echo $str{2}; //这里输出的是t
?>
这里的{}等同于[],效果一样。
4:
$a=10;$b=10;$c=11;
$a==$b $c=19;
echo $c; //$c=19
对于js:
console.log( 5=='5' && 6 || 7);
输出6,改成5==10呢,输出7了。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment