note 87296 modified in function.eval by danbrown

From: Date: Sun, 17 May 2009 19:51:00 +0000
Subject: note 87296 modified in function.eval by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155278@lists.php.net to get a copy of this message
Magic constants like __FILE__ may not return what you expect if used inside eval()'d code. Instead, it'll answer something like "c:\directory\filename.php(123) : eval()'d code" (under Windows, obviously, checked with PHP5.2.6) - which can still be processed with a function like preg_replace to receive the filename of the file containing the eval(). Example: <?php $filename = preg_replace('@\(.*\(.*$@', '', __FILE__); echo $filename; ?> --was-- Magic constants like __FILE__ may not return what you expect if used inside eval()'d code. Instead, it'll answer something like "c:\directory\filename.php(123) : eval()'d code" (under Windows, obviously, checked with PHP5.2.6) - which can still be processed with a function like preg_replace to receive the filename of the file containing the eval(). Example: $filename = preg_replace('@\(.*\(.*$@', '', __FILE__); echo $filename; http://php.net/manual/en/function.eval.php

« previous php.notes (#155278) next »