0
0

More than 3 years have passed since last update.

【PHP】メソッド内で関数の呼び出し Fatal error: Call to undefined functionエラー

Last updated at Posted at 2021-01-02

メソッド内で関数を呼び出そうとすると、「Fatal error: Call to undefined function...(未定義の関数を呼び出そうとしている)」というエラーになります。


//Fatal error: Call to undefined function...
class Example
function a(){ 
  echo 'Hello';
}
function b(){
  a();
}

メソッド内で異なるメソッドを呼び出す場合は、「$this->メソッド名()」と明記するとエラーを解決できます。


class Example
function a(){ 
  echo 'Hello';
}
function b(){
  $this->a();
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0