Re: Exceptions and Errors
| From: | Brad Fisher | Date: | Thu, 15 Apr 2004 16:33:32 +0000 |
| Subject: | Re: Exceptions and Errors | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9194@lists.php.net to get a copy of this message | ||
Lukas Smith wrote:
> > Our original idea was to handle this with an if statement like so:
> > if (version_compare(phpversion(), "5.0.0") == -1) {
> > // assign factoried method to this for PHP 4
> > // $this =& <Your_Package_Name>::factory();
// $this =& <Your_Package_Name>::singleton();
eval('$this =& <Your_Package_Name>::singleton();');
> > } else {
> > // error handling for PHP5
> > // user has to use the factory()/singleton() method
> > }
>
> I guess to make it clear, what I want is that PHP5 only explodes if it
> is actually asked to execute an assignement to $this and not just
> because there is one in the constructor. However Derick just messed
> around with the relevant code and didnt immediatly see a solution.
So what's wrong with using eval to evaluate the non-PHP5 compatible code?
Besides the performance penalty, of course. The code in the eval itself
will never be parsed or executed in PHP5. Seems to work for me at
least...
> regards,
> Lukas Smith
-Brad