the magic of PHP variable function

<?php
$func = "sqrt";
if (is_callable($func)) {
print $func(49);
}
//result 7
?>

Alternatively you can use call_user_func() and call_user_func_array()

call_user_func is twice slower than direct call function and call_user_func_array is 10%-20% slower than call_user_func

more info

Advertisements

Published by

paragasu

Different. In a good way

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s