|
Posted by ZeldorBlat on 05/02/07 21:54
On May 2, 4:17 pm, "_mario.lat" <n...@libero.it> wrote:
> Hallo,
> I use a class vith a vaiables.
> When a function throws an exception it seems to loose data:
>
> ...
> $c=new myclass();
> try{
> $a->var1=1;
> $a->function_throw_exception(); <--- this throws an exception
> ...}
>
> catche(exception $e)
> {
> $a->var1; <--- is empty ?!?!
>
> }
>
> The code is more complex but the idea is this.
> it is possible?
> what do you think?
> Thankyou in advance,
> Mario.
When I run th following code it works as expected, echo'ing "baz":
class Foo {
public $x;
public function bar() {
throw new Exception();
}
}
$f = new Foo();
try {
$f->x = 'baz';
$f->bar(); //this throws an exception
} catch (Exception $e) {
echo $f->x; //this correctly prints "baz"
}
Navigation:
[Reply to this message]
|