Jay Moore schreef:
> Good ideas guys.  The input is much appreciated.
> 
> Jochem (and anyone else, I guess), as I am not 100% versed with
> Exceptions, the php5 version you suggested, are those Exceptions able to
> be handled outside the class?
> 
> Do I need my try block to be within the class block, or can I have the
> try block be in my normal code where I actually instantiate the class?
> 
> This:
> 
> class blah
> {
>     try { stuff } catch (exception) { more stuff }
> }
> 
> $i = new blah()

no, this does not work, 'snot even valid syntax.

> 
> or can I do this:
> 
> class blah
> {
>     do some stuff (no try/catch blocks here)
>     throw an exception
> }
> 
> try
> {
> 
>     $i = new blah();
>     more stuff
> }
> catch (exception) { even more stuff }

yes.

try {
        $db = new do_mysql('root', 'pass', 'mydb');
} catch (Exception $e) {
        // var_dump($e); // debug
        // could not connect, deal with it.
}

// do some stuff

try {
        $db->query($myQry);
} catch (Exception $e) {
        // bad query, deal with
}

... etc, etc

> Thanks,
> Jay
> 


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

Reply via email to