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.
融合阿里雲,牛客助您找到心儀好工作
2.
解決jdbc(jdbctemplate)在測試類時不報錯在TomCatb部署後報錯
3.
解決PyCharm GoLand IntelliJ 等 JetBrains 系列 IDE無法輸入中文
4.
vue+ant design中關於圖片請求不顯示的問題。
5.
insufficient memory && Native memory allocation (malloc) failed
6.
解決IDEA用Maven創建的Web工程不能創建Java Class文件的問題
7.
[已解決] Error: Cannot download ‘https://start.spring.io/starter.zip?
8.
在idea讓java文件夾正常使用
9.
Eclipse啓動提示「subversive connector discovery」
10.
帥某-技巧-快速轉帖博主文章(article_content)
本站公眾號
歡迎關注本站公眾號,獲取更多信息
相關文章
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的用法
>>更多相關文章<<