php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43142 Call different function
Submitted: 2007-10-30 13:07 UTC Modified: 2007-10-30 16:51 UTC
From: felipensp at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3CVS-2007-10-30 (snap) OS: Linux
Private report: No CVE-ID: None
 [2007-10-30 13:07 UTC] felipensp at gmail dot com
Description:
------------
Return of create_function() concat. with 'foo'.
But, when calling the function with the name of variable's value, only 'foo' is used...

Reproduce code:
---------------
<?php

$a = 'foo'. create_function('', 'print "foo!";');

var_dump($a); // string(12) "foolambda_1"

function foo() { print 1; }

$a();         // Fatal error: Call to undefined function foo()

// foo() ?!


Expected result:
----------------
Fatal error: Call to undefined function foolambda_1()

Actual result:
--------------
string(12) "foolambda_1"

Fatal error: Call to undefined function foo()

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-30 16:51 UTC] johannes@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

Mind the 12 as length of oyur output - the actual name of the lambda function is \"\\0lambda_1\" but your terminal/browser doesn\'t dispaly the null byte.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 21:01:33 2025 UTC