OOP中->与:操作符的差别

WBOY
Release: 2016-06-13 12:03:24
Original
1065 people have browsed it

OOP中->与::操作符的区别
OOP中->与::操作符的区别有哪些?度娘不给力,找不到
------解决方案--------------------
static关键字修饰的变量,外部调用只能是::
static关键字修饰的方法,外部调用->和::皆可,习惯上用::,静态方法不能操作非静态变量
暂时想到就这些,楼下补充

------解决方案--------------------
->是实例调用
::是类中静态方法和静态属性的引用方法



------解决方案--------------------
-> 表示对象的成员
:: 作用域分辨运算符。手册中说:在没有声明任何实例的情况下访问类中的函数或者基类中的函数和变量很有用处。而 :: 运算符即用于此情况。
虽然 php 5.3 以后对 :: 的用法做了点限制,但总体并没有太大出入

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!