note 128564 added to language.constants.magic

From: Date: Mon, 22 May 2023 02:12:58 +0000
Subject: note 128564 added to language.constants.magic
Groups: php.notes 
Request: Send a blank email to php-notes+get-220519@lists.php.net to get a copy of this message
The __DIR__ not exists at PHP5.2 or before, that's added in PHP5.3 or earlier. so if you use PHP5.2 you can make the constant yourself, to prevent script errors also "You cannot check if a magic constant is defined. This means there is no point in checking if __DIR__ is defined then defining it. defined('__DIR__') always returns false." <?php $dir = @__DIR__; if( $dir=='__DIR__' ) { // not defined $cwd = ''; if( function_exists('getcwd') ) { $cwd = getcwd(); } if( $cwd==false || empty($cwd) ) { $cwd = dirname(__FILE__); } define('__DIR__', $cwd); } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.13.130 (proxied: 109.123.74.182) ---- Manual Page -- https://php.net/manual/en/language.constants.magic.php Edit -- https://main.php.net/note/edit/128564 Del: integrated -- https://main.php.net/note/delete/128564/integrated Del: useless -- https://main.php.net/note/delete/128564/useless Del: bad code -- https://main.php.net/note/delete/128564/bad+code Del: spam -- https://main.php.net/note/delete/128564/spam Del: non-english -- https://main.php.net/note/delete/128564/non-english Del: in docs -- https://main.php.net/note/delete/128564/in+docs Del: other reasons-- https://main.php.net/note/delete/128564 Reject -- https://main.php.net/note/reject/128564 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220519) next »