I'm hoping someone here knows the answer to this. I wrote a script that uses
basename( __DIR__ )
then uses an if file exist function.
On my server this works fine, however on other sever it actually returns the word _DIR_
instead of the file path.
Did this change with a version of PHP or is there some other setting that makes it so this doesn’t work?
Lastly is there a better way to get the path of the file? Here is the whole line I’m using:
define('NIFTY_CONSTANT', trailingslashit (WP_PLUGIN_DIR . '/'. basename( __DIR__ ) ). '/lib/mdetect.php' );
(yes I know it's a WordPress function but this is not a WordPress question it's a PHP one)
__DIR__
is introduced in PHP 5.3 . Double check your PHP version .
Reference: http://php.net/manual/en/language.constants.predefined.php