Bug #69921 [Opn]: function_exists returns true before function definition
| From: | alan at aondra dot com | Date: | Wed, 24 Jun 2015 15:10:45 +0000 |
| Subject: | Bug #69921 [Opn]: function_exists returns true before function definition | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193848@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69921&edit=1
ID: 69921
User updated by: alan at aondra dot com
Reported by: alan at aondra dot com
-Summary: function_exists fires before function definition
+Summary: function_exists returns true before function
definition
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: Any
PHP Version: 5.6.10
Block user comment: N
Private report: N
New Comment:
.
Previous Comments:
------------------------------------------------------------------------
[2015-06-24 14:57:52] alan at aondra dot com
Gave a better summary
------------------------------------------------------------------------
[2015-06-24 14:56:19] alan at aondra dot com
Description:
------------
---
From manual page: http://www.php.net/function.function-exists
---
The function 'function_exists' does not execute in the order in which the code is
evaluated. Not only is this wrong, it allows for the possibility that code could be executed in the
incorrect scope.
I saw this note on the documentation:
"A function name may exist even if the function itself is unusable due to configuration or
compiling options (with the image functions being an example)."
I looked and found no such configuration or compiling option that would allow for this.
Test script:
---------------
<?php
header('Content-Type: text/plain');
$mystr = 'should not execute';
if(function_exists('myfunc'))
{ myfunc($mystr); }
$mystr = 'execute';
function myfunc($str)
{ die($str); }
myfunc($mystr);
Expected result:
----------------
execute
Actual result:
--------------
should not execute
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69921&edit=1