/    Sign up×
Community /Pin to ProfileBookmark

Error: Function name must be a string

I implemented a debug function which utilizes some messaging I’ve implemented. However, when I put the function call into my code, I get the above error message. The function is contained in an include file which is conditionally included as follows (ahead of all others):

if( !isset($Debug) )
$Debug = TRUE; // force for testing
if( $Debug ) {
include(“debug.php”);
} else if( !function_exists(‘dbg’) ) {
function dbg() { return; }
}

I’ve verified that $Debug is in fact TRUE and that the function_exists(‘dbg’) call is returning TRUE.

However, when contained in another include file (that follows the inclusion of debug.php) I get the above error. Snippet of the line referenced by the interpeter is:

dbg(sprintf(“cfgInfo: Level is %d, Top is %d, AppID=%d Ent=%d, Com=%d, Sit=%d, Usr=%d”, $level, $top,
$cfgID(‘cfgAppID’), $cfgID[‘cfgEntID’], $cfgID[‘cfgComID’], $cfgID[‘cfgSitID’], $cfgID[‘cfgUsrID’]), dbgCFGDATA );

‘dbgCFGDATA’ is defined in debug.php as define(‘dbgCFGDATA’, 0xf0000000);

The actual dbg() function from my debug.php is (you’ll have to trust me that the messaging does work correctly):

function dbg($s, $lev=dbgALL, $prop=”) {
global $Debug;
if( ! isset($Debug) || !($Debug & $lev) ) // not for this one
return;
addMessage($s, ‘debug’, $prop);
}

Pretty simple all the way around. Psuedo code description expected to be:
Main:
If $Debug is not set, set it to TRUE
if $Debug is TRUE then include debug.php
else create a function that does nothing so the code doesn’t break.
Include File:
call the dbg() function from the code.

I did a google search for the above error but it turned up the question once with no real answer supplied as to the cause (got into a pissing match about code style, etc.).

Anyone have any pointers that can help me out?

thanks,
tony

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@tbirnsethauthorOct 06.2005 — Well, I found the problem. It seems that I had a pair of parens ()' around the index of an array element instead of brackets []'s. Hence it was looking at a variable as a function. I.e.

Wrong: $arName('myindex')

Right: $arName['myindex']

Ugh! Anyone want to donate a younger pair of eyes? ?
Copy linkTweet thisAlerts:
@agent_x91Oct 06.2005 — Ugh! Anyone want to donate a younger pair of eyes? [/QUOTE]

How much will you pay for them? I'll pluck mine out if the price is right? lol

By the way everyone please remember to use code tags for code (and php tags for php)
Copy linkTweet thisAlerts:
@DrakhelmNov 07.2007 — There's also another problem that will cause the same type of response (function must be a string) and that's inadvertently including a $ in front of a predefined/language defined function.
Copy linkTweet thisAlerts:
@DrakhelmNov 07.2007 — $cfgID('cfgAppID')

and I think I see the error you were referring too.
×

Success!

Help @tbirnseth spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...