Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: PHP: Weird Exception Handling Error |
|
Author |
|
SabinF
Joined: 03 May 2006 Posts: 37 Location: Timisoara (Romania)
|
Posted: Sun 13 May '07 9:29 Post subject: PHP: Weird Exception Handling Error |
|
|
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: 7360 Location: Germany, Next to Hamburg
|
Posted: Sun 13 May '07 21:36 Post subject: |
|
|
$this->PrintMessage($e->getMessage());
or
MyClass::PrintMessage($e->getMessage());
You should you the first one, that is oop
Some usefull page (RTM) http://www.php.net/oop |
|
Back to top |
|
SabinF
Joined: 03 May 2006 Posts: 37 Location: Timisoara (Romania)
|
Posted: Mon 14 May '07 7:15 Post subject: |
|
|
Thanks so much, this detail has slipped right through my fingers... I can't believe I forgot this. |
|
Back to top |
|
|
|
|
|
|