logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


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

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: PHP: Weird Exception Handling Error
Author
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: 7371
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


Reply to topic   Topic: PHP: Weird Exception Handling Error View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner