> On 19 Nov 2014, at 15:07, Alain Williams <a...@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/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php