eval() And __FILE__¶
<?php
eval(' echo "__FILE__ is not `'.__FILE__.'` in `" . __FILE__."`"; ');
__FILE__ is a magic constant that holds the current file full path. This is not true when using it inside eval(), which comes with an extra suffix that tell it is executed in eval(). In fact, eval() has its own __FILE__, since it is executed in a sandboxed and temporary area.
See Also¶
__FILE__ in eval() [Try me]
PHP Features¶
Last updated: 14 July 2026