View Single Post
Old 10-02-2008, 03:51 AM   #2 (permalink)
Kalle
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

Your code is sort of wrong, you cannot return a value in a contructor or destructor, you can only catch these sort of values if they are staticlly declared, but non of the magic methods may be declared staticlly.

To detect an error you should use Exceptions, instead of the return false part in your constructor you say:
PHP Code:
throw new Exception('<error message goes here>'); 
And you replace this part:
PHP Code:
$image = new image("$upload"); 
With this to catch the exception:
PHP Code:
try
{
    
$image = new image($upload);
}
catch(
Exception $e)
{
    echo 
$e->getMessage();

You can also use a default exception handler using the set_exception_handler() function.

For more information about the methods that the Exception class exposes, then referer to the php.net docs here:
PHP: Exception - Manual
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote