JavaShuo
欄目
標籤
PHP中的$this用法
時間 2019-11-19
標籤
php
用法
欄目
PHP
简体版
原文
原文鏈接
[php]
view plain
copy
print
?
<?php
class human{
public
$name=
"李四";
public
function eat(){
echo
$this->name,
'在吃飯';
}
public
function test(){
echo
$name,
'在吃飯';
}
}
$li=
new human();
echo
$li->name;
//李四
$li->eat();
//李四在吃飯。
/*
和java,c++相比
方法體內想訪問調用者的屬性,必須用$this
若是不加,則理解爲方法內部的一個局部變量.
*/
$li->test();
//Notice: Undefined variable: name in C:\wamp\www\php\this.php on line 14
/******
從生活中的角度來理解$this
女媧造人時, 造了一個"悔恨"的方法
{
抓[本身]頭髮
抽 [本身] 臉
}
世界上的人那麼多,
悔恨時,抓誰的頭髮?
抽誰的臉?
張三,李四? 王五? 都不能說明合理的狀況
只能理解爲"本身"
******/
?>
相關文章
1.
php中self和$this的用法
2.
php中this,parent和self的用法
3.
PHP中this語句的用法
4.
PHP $this->方法調用
5.
jquery中this與$(this)的用法區別
6.
js中this的用法
7.
Java中this的用法
8.
JS中this的用法
9.
C#中this的用法
10.
vue中 this.$set的用法
更多相關文章...
•
Spring中Bean的作用域
-
Spring教程
•
Redis在Java Web中的應用
-
Redis教程
•
C# 中 foreach 遍歷的用法
•
適用於PHP初學者的學習線路和建議
相關標籤/搜索
php中的curl
中法
中用
用法
用的
this+call
c++this
this#6
with+this
1+this
PHP
PHP教程
PHP參考手冊
PHP 7 新特性
PHP
應用
算法
0
分享到微博
分享到微信
分享到QQ
每日一句
每一个你不满意的现在,都有一个你没有努力的曾经。
最新文章
1.
吳恩達深度學習--神經網絡的優化(1)
2.
FL Studio鋼琴卷軸之工具菜單的Riff命令
3.
RON
4.
中小企業適合引入OA辦公系統嗎?
5.
我的開源的MVC 的Unity 架構
6.
Ubuntu18 安裝 vscode
7.
MATLAB2018a安裝教程
8.
Vue之v-model原理
9.
【深度學習】深度學習之道:如何選擇深度學習算法架構
本站公眾號
歡迎關注本站公眾號,獲取更多信息
相關文章
1.
php中self和$this的用法
2.
php中this,parent和self的用法
3.
PHP中this語句的用法
4.
PHP $this->方法調用
5.
jquery中this與$(this)的用法區別
6.
js中this的用法
7.
Java中this的用法
8.
JS中this的用法
9.
C#中this的用法
10.
vue中 this.$set的用法
>>更多相關文章<<