logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



PHP: Weird Exception Handling Error

 
Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner



View previous topic :: View next topic  
Author Message
SabinF



Joined: 03 May 2006
Posts: 37
Location: Timisoara (Romania)

PostPosted: Sun 13 May '07 9:29    Post subject: PHP: Weird Exception Handling Error Reply with quote

Hello! I'm trying the following scenario and it doesn't seem to work.

Code:
class MyClass
{
public function MyFunction()
{
try
{
if($x)
{
// Do something
}
else
{
throw new Exception("Message");
}
catch(Exception $e)
{
PrintMessage($e->getMessage());
}
}

private function PrintMessage($message)
{
// Print message in html.
}
}


The error I get is:

Code:
PHP Fatal error:  Call to undefined function PrintMessage() in ... on line ...
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6255
Location: Germany, Next to Hamburg

PostPosted: Sun 13 May '07 21:36    Post subject: Reply with quote

$this->PrintMessage($e->getMessage());

or

MyClass::PrintMessage($e->getMessage());

You should you the first one, that is oop Wink

Some usefull page (RTM) http://www.php.net/oop
Back to top
SabinF



Joined: 03 May 2006
Posts: 37
Location: Timisoara (Romania)

PostPosted: Mon 14 May '07 7:15    Post subject: Reply with quote

Thanks so much, this detail has slipped right through my fingers... I can't believe I forgot this. Rolling Eyes
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner
Page 1 of 1