Calling a function dynamically

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aliasxneo
Forum Contributor
Posts: 136
Joined: Thu Aug 31, 2006 12:01 am

Calling a function dynamically

Post by aliasxneo »

Is there any difference between these lines of code:

Code: Select all

$result = $funcName();

Code: Select all

$result = call_user_func($funcName);
Is there anything PHP does in the background with call_user_func() that is important and/or necessary?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Calling a function dynamically

Post by John Cartwright »

Significant changes in the background? No. The only real difference is how errors are handled.
aliasxneo
Forum Contributor
Posts: 136
Joined: Thu Aug 31, 2006 12:01 am

Re: Calling a function dynamically

Post by aliasxneo »

Jcart wrote:Significant changes in the background? No. The only real difference is how errors are handled.
I see. So instead of the normal error reporting call_user_func will just return false?
Post Reply