PHP关键字"var"有什么作用? [英] What does PHP keyword 'var' do?

查看:82
本文介绍了PHP关键字"var"有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常琐碎的问题,但是我既无法通过网络搜索引擎也无法在php.net上找到答案.如果您没有时间解释,请直接将我定向到可以阅读的内容.

This is probably a very trivial question, but I haven't been able to find the answer neither through web search engines, nor on php.net. Please just direct me to where I can read about this, if you haven't got time to explain.

  1. 'var'关键字在PHP中是什么意思?
  2. PHP4和PHP5之间有什么区别吗?

推荐答案

它用于在PHP4中声明类成员变量,不再需要.它将在PHP5中运行,但是从不推荐使用的版本开始,从PHP 5.0.0版本到5.1.2版本将发出E_STRICT警告.从PHP 5.3开始,var被弃用,并且是'public'的同义词.

It's for declaring class member variables in PHP4, and is no longer needed. It will work in PHP5, but will raise an E_STRICT warning in PHP from version 5.0.0 up to version 5.1.2, as of when it was deprecated. Since PHP 5.3, var has been un-deprecated and is a synonym for 'public'.

示例用法:

class foo {
    var $x = 'y'; // or you can use public like...
    public $x = 'y'; //this is also a class member variables.
    function bar() {
    }
}

这篇关于PHP关键字"var"有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆