Closed Geczy closed 12 years ago
You could also opt to do this if you'd like:
<?php
if ( !defined('__DIR__') ) define('__DIR__', dirname(__FILE__));
I'll make the changes for the example files, but I'm not accepting the change to php_error.
The only users that will see T_DIR are those on 5.3 and beyond, and there it is an alias for 'DIR' and not dirname(FILE).
DIR is also only used in php_error for error messages, we aren't actually using the constant DIR. It's so you get "unexpected DIR" instead of "unexpected T_DIR", as the first will be matching actual user code (they have to write an unexpected DIR to get that message).
It's to complement others, such as 'unexpected ::' instead of 'unexpected T_PAAMAYIM_NEKUDOTAYIM'.
I'm planning to just define the numeric tokens for these value if they are not present, with their future values. I'd rather bolt on workarounds for 5.0, then bolt on workarounds that affect 5.3 code, as eventually the 5.0 workarounds could be dropped.
The magic constant
__DIR__
isn't available with PHP <5.3http://php.net/manual/en/language.constants.predefined.php