Bug #69921 [Opn->Nab]: function_exists returns true before function definition
| From: | cmb@php.net | Date: | Wed, 24 Jun 2015 17:09:07 +0000 |
| Subject: | Bug #69921 [Opn->Nab]: function_exists returns true before function definition | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193853@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
Updated by: cmb@php.net
Reported by: alan at aondra dot com
Summary: function_exists returns true before function
definition
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: Any
PHP Version: 5.6.10
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
According to the documentation[1]:
| Functions need not be defined before they are referenced, [...]
function_exists() yields a result accoring to this, i.e. where
a function can be called, function_exists() returns true.
[1] <http://php.net/manual/en/functions.user-defined.php>
Previous Comments:
------------------------------------------------------------------------
[2015-06-24 15:10:45] alan at aondra dot com
.
------------------------------------------------------------------------
[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