php
PHP
$this
- クラス内の関数からクラスのメンバを参照する際に使用するらしい 1)
<?php class FruitClass{ public $fruit = 'Apple'; //メソッドの宣言 public function FruitMethod(){ $fruit = 'Grape'; echo $fruit; //Grapeが出力 echo $this->fruit; //Appleが出力 } } //インスタンスの生成 $class = new FruitClass(); //メソッドの呼出し $class->FruitMethod(); ?>
1)
『PHP 擬似変数$thisとは何??』, Qiita, https://qiita.com/yyyykkkk/items/9de1a74b2b0f054bd392, 2021/04/20
php.txt · 最終更新: 2021/09/29 08:51 by 127.0.0.1