Home  >  Article  >  Backend Development  >  php中的var宣言的作用

php中的var宣言的作用

WBOY
WBOYOriginal
2016-06-13 10:34:11910browse

php中的var声明的作用?
刚学不久的PHP,但即使《PHP圣经》涉及知识面很广的教材也没有提到PHP可以用var声明变量,但看网络上的一书类,用到了VAR来声明变明。如:

class test{
  var $a;
  var $b;
  ......
}


我测试了一上,好像var只能在类中使用,如果类以外使用会出错(PHP5.3)。

目前所能总结的也就这点了,哪位能系统讲一下这个关键字的其它作用?

------解决方案--------------------
PHP5中public就等同于var了
只是为了兼容PHP4,所以还保留var
------解决方案--------------------
向前兼容性

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