run code in 200+ php & hhvm versions
Bugs & Features
<?php // In response to http://www.php.net/manual/en/language.constants.predefined.php#113130 // In fact, you can define magic constants too. if (@__DIR__ == '__DIR__') { echo "magic __DIR__ constant NOT defined\r\n"; echo "defining __DIR__ constant\r\n"; define('__DIR__', substr(__FILE__, 0, strrpos(__FILE__, DIRECTORY_SEPARATOR))); } else { echo "magic __DIR__ constant IS defined\r\n"; } echo "result of var_dump(__DIR__):\r\n"; var_dump(__DIR__);
Output for 5.3.0 - 7.1.7
magic __DIR__ constant IS defined result of var_dump(__DIR__): string(3) "/in"
Output for 4.3.0 - 5.2.17
magic __DIR__ constant NOT defined defining __DIR__ constant result of var_dump(__DIR__): string(3) "/in"