php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41139 include() & eval() scope
Submitted: 2007-04-19 17:12 UTC Modified: 2007-04-19 19:36 UTC
From: tim dot brown at bedspace dot co dot uk Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.1 OS: Win XP
Private report: No CVE-ID: None
 [2007-04-19 17:12 UTC] tim dot brown at bedspace dot co dot uk
Description:
------------
When you use an include() or eval() within a function, return() does not end execution of the function. Also __FUNCTION__ does not work within an include() or eval() within a function.

Reproduce code:
---------------
<?php
function test(){
  eval("echo __FUNCTION__;");

  eval("return 123;");
  return "abc";
}

$x = test();

var_dump($x);
?>

Expected result:
----------------
I would expect to see:
test int(123)



Actual result:
--------------
output:
string(3) "abc"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-19 19:36 UTC] tony2001@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

This is expected behaviour.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Apr 02 16:00:01 2026 UTC