Jump to content

Fatal error: Call to undefined method


mallen

Recommended Posts

class MyDisplay 
{

function displayToday()
	{
		
		$today = "Thursday";
		{
		echo $today;
		}
		
		
	}
function displayTomorrow()
	{
		
		$tomorrow = "Friday";
		{
		echo $tomorrow;
		}
		
		
	}

}


$disp = new MyDisplay();


echo $disp->displayToday();
echo displayTomorrow();//fails is I have $disp->

I simplified my code for explanation. One class with two methods. When I try to use the method I get this error. Fatal error: Call to undefined method MyDisplay::displayTomorrow()

Link to comment
https://forums.phpfreaks.com/topic/288998-fatal-error-call-to-undefined-method/
Share on other sites

your posted code, with the last line change to echo $disp->displayTomorrow();, runs correctly.

 

we will need to see the actual code that produces the error in order to help you with what is wrong with it. you either have a spelling or scope or conditional definition problem.

  Quote
They is just too much to post here

 

 

if you have a class definition that contains too much code to post, you are doing something wrong. the only code that's relevant is the class definition, the code making an instance of that class, and the code where you are calling the method/getting the error.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.