php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49455 eval works or not with __FILE__ and basename
Submitted: 2009-09-03 13:13 UTC Modified: 2009-09-03 14:50 UTC
From: djalmaoliveira at gmail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.10 OS: Ubuntu
Private report: No CVE-ID: None
 [2009-09-03 13:13 UTC] djalmaoliveira at gmail dot com
Description:
------------
When I execute this code, the first eval() works, but the second breaks.

It's a bug?



Reproduce code:
---------------
eval('echo dirname(__FILE__);');
echo "<br>";
eval('echo basename(__FILE__);');


Expected result:
----------------
The second eval() works.

Actual result:
--------------
The second eval(): eval()'d code


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-03 14:50 UTC] sjoerd@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Basename does work. However __FILE__ contains the following:
/home/sjoerd/public_html/a.php(2) : eval()'d code

This makes basename(__FILE__) contain:
a.php(2) : eval()'d code

So the behavior is expected.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 27 00:00:03 2025 UTC