Re: exception handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sandro Felicioni wrote:
Hello,

I've a question regarding the exception handling in PHP 5.

In my php script I created a try catch block in order to catch throwing exceptions. The problem is that my try - block starts at the end of a php file, but ends in a different one. This always leads to the following error: "Parse error: syntax error, unexpected $end ".
I hope you could tell me how to resolve this problem.

Thanks and kind regards
Sandro Felicioni

e.g.:

start top.php
-------------

try{

end top.php
-----------

start main.php
--------------

require_once("top.php");

execute some critical php code

}catch(Exception $e){
  doSomething();
}

end main.php
--------------
end main.php
------------

Hello,

PHP considers each file a separate php script and because of that you will have to end any blocks opened before the file ends. The way you're doing it in your example would simply not work. Try putting the try block and the start of main.php.

Runar

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux