Home > Backend Development > PHP Tutorial > PHP this binding

PHP this binding

不言
Release: 2023-03-24 20:30:01
Original
1397 people have browsed it

The content introduced in this article is about PHP this binding, which has certain reference value. Now I share it with everyone. Friends in need can refer to it

About this binding

class Human {
    public $name = 'lisi';    public function who() {
        echo $this->name;
    }    /*
    public function test() {
        echo $name;
    }
    *//*
和java、c++相比
方法体内想访问调用者的属性,必须用$this
如果不加,则理解为方法内部的一个局部变量.
*/}$a = new Human();echo $a->name,&#39;<br >&#39;; //lisi$a->who(); //lisi//$a->test();
Copy after login

PHP this binding


The above is the detailed content of PHP this binding. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Issues
Why is this ID written like this?
From 1970-01-01 08:00:00
0
0
0
Small question about $this
From 1970-01-01 08:00:00
0
0
0
What's the use of this?
From 1970-01-01 08:00:00
0
0
0
This file demo.mp4
From 1970-01-01 08:00:00
0
0
0
javascript - es6中this
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template