I have a little question here. This is my code: DB::beginTransaction(); try{ $created = new TransportTypeColumn(); $created->name = $translated_ids[0]; if(!$created-&…
Tag: exception-handling
What happens with set_error_handler() on PHP7 now that all errors are exceptions?
On PHP5 it makes a whole lot of sense having both set_exception_handler() and set_error_handler() defined. However, on PHP7 all (most?) errors are now exceptions. So, what’s the point on defining …
Why isn’t my PHP exception working?
I am new to exceptions in PHP or any language really. I am trying to catch an exception if a user enters an invalid textual timezone (“xxxxxxxxxx” in this case). My test case is definitely invalid as an exception is triggered, just not the catch logic which is supposed to handle it intelligently. Basically I want it to use a
PHP variable scope within Try/Catch block
In PHP, how do variable scope rules apply to Try/Catch blocks? Do variables declared within the try block go out of scope when the block has finished? Or are they in scope until the end of the function/method? For example: Is this valid? Or should $o = NULL; be set before the try/catch to keep $o in scope? (I know
PHP: Append to thrown exception message
Take the following function as an example of what I want to do: public function save() { $this->connect(‘wb’); try { if(!$this->lock()) throw new Exception(“Unable …