Home > Backend Development > PHP Tutorial > . 和 -> 的区别

. 和 -> 的区别

WBOY
Release: 2016-06-23 14:12:13
Original
1142 people have browsed it

新手问些基础知识,求大神解答,谢谢


回复讨论(解决方案)

在php中
. 是字符串连接符
-> 对象取属性或方法运算符

不要把其他语言中的.含义带到php中

如#1所说.
是连接符用于变量的链接
$a="abc";$b=""efg";
echo $a.$b;
->通常是类中用于调用属性或方法
class a{
 public function a(){
    $a=5;
    return $a;
 }
$b=new a();
echo $b->a();

php .是连接  其他的 比如 c# 中访问类中成员方法时用的是.  相当于php->

我是来学习的

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