Re: [RFC] Remove PHP 4 Constructors

From: Date: Wed, 19 Nov 2014 15:10:27 +0000
Subject: Re: [RFC] Remove PHP 4 Constructors
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-79001@lists.php.net to get a copy of this message
> On 19 Nov 2014, at 15:07, Alain Williams <addw@phcomp.co.uk> wrote: > > It is a problem trying to maintain code for different versions of PHP, > especially where there are syntax differences. It would be really nice to have > some sort of conditional compilation as in C. Eg: > > It would be nice to be able to do something like: > > try { > .... > > # if PHP_VERSION_ID > 50500 > } catch(PDOException $e) { > .... > } finally { > ... tidy up > } > # else > } catch(PDOException $e) { > ... tidy up not quite where I want it > .... > } > # endif > > OK: '#' might not be a good character since it is start of comment, but that is > the idea. You could actually run the C preprocessor on your PHP codebase if you wanted! But yes, I can see there might be a need for conditional compilation. To a certain extent we already have this, in that you can conditionally define functions and classes. Perhaps this could be extended? Conditionally defining methods? class FooBar { if (PHP_VERSION_ID < 50000) { public function FooBar() { $this->__construct(); } } public function __foobar() { } } -- Andrea Faulds http://ajf.me/

« previous php.internals (#79001) next »