473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

"function_exists" Returns Nothing

Has anyone had experience with "function_exists" not finding a function
that you KNOW you've defined? I have defined a function we'll call
"foo":

1. I know that function has been parsed, because code lower down the
script executes a function in the same include file.

2. The function name appears in the "get_defined_functions" array.

3. If I just call the function (without bothering to check if it
exists), I get a return value, so the function is there.

4. if(function_exists('foo')) evaluates as false (so does
if(function_exists('foo') == true), for that matter)

5. print_r(function_exists('foo')) prints nothing to the screen.

I've experimented with case to no success. function_exists is supposed
to be case-insensitive, but it doesn't seem to matter. The function
name is in lower case in get_defined_functions, but looking for it with
any type of case doesn't matter -- it's just not found.

I have to be doing something wrong, but I can't figure out what.

Deane

Jul 17 '05 #1
5 2498
Try this code:

ini_set('display_errors', 1);
error_reporting(E_ALL);
if (function_exists('foo')) {
echo "This function exists";
} else {
var_dump(function_exists('foo'));
foo();
}

Jul 17 '05 #2
Try this code:

ini_set('display_errors', 1);
error_reporting(E_ALL);
if (function_exists('foo')) {
echo "This function exists";
} else {
var_dump(function_exists('foo'));
foo();
}

Jul 17 '05 #3
It returns nothing. I tried your code and go nothing. So I set the
error reporting to the strictest level I possible could, and just did
this:

var_dump(function_exists('foo'));

Nothing. I even had to a put a die() right after it to make sure
var_dump executed. It seems that function_exists is
returning...nothing. Not even a false.

Deane

Jul 17 '05 #4
Then it's something else as var_dump() will always print something
here. Always.

My gut tells me that the display_errors directive is off in php.ini and
a fatal error exists. In this case, display_errors cannot be set at
runtime and you'll get a blank page.

Jul 17 '05 #5
Well, I upgraded the PHP version to 4.3.11 and var_dump is now
returning something from function_exists -- but it's false.

I'm at a roadblock here. function_exists refuses to accept that the
function is there, even though every other indicator comes back true.

I think I'm just going to hack up a user function that does an
array_search on get_defined_functions, ugly as that sounds.

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: |-|erc | last post by:
<?php // Get the names and values for vars sent by index.lib.php3 if (isset($HTTP_GET_VARS)) { while(list($name,$value) = each($HTTP_GET_VARS)) { $$name = $value; }; };
4
by: futureofphp | last post by:
I need to access a website, Fetch the data, and then logout. Please tell me where I am wrong. I dont think its logging out properly. <? include "Snoopy.class.php"; $snoopy = new Snoopy; ...
5
by: comp.lang.php | last post by:
$orderBy = 's.app_date desc, s.last_name asc, s.first_name asc, s.mi asc'; if ($_REQUEST) { $ascArray = array('asc' => 'desc', 'desc' => 'asc'); // ARRAY OF ALL ORDERING POSSIBILITIES $junk =...
19
by: lawrence k | last post by:
How can I find out where my script is outputting to the screen for the first time? My error logs are full of stuff like this: PHP Warning: session_start(): Cannot send session cache...
18
by: JohnDriver | last post by:
Hi, I am happy to say that with your help, I have been performing good in Ajax. Thanks for helping me to start with. I have a small problem now. I am pulling records from database and passing...
1
by: nwclark | last post by:
I am a noobie so pleas bear with me.. I am trying to link a image to a MYSQL variable. I have user photos that i would like to link this page. So far I created an image upload and renamed the...
2
by: jeddiki | last post by:
Hello, I want to create my own index of websites based on my criteria rather than big G's. For example, I might like to index websites according to what they have in their "author" Meta tag (...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.