Jump to content

[SOLVED] tricky php question


rsalumpit

Recommended Posts

$POINT = "foobar";

Function foobar($how_bar);

{

Echo  "not just foobar, $how_bar  foobar.";

}

 

How can you call the function foobar("really"); without directly calling the function foobar. Hint (use $POINT );

 

my answer is this but i dont think is correct

echo $POINT.'("really");';

Link to comment
Share on other sites

Whoops, my fault. I read that wrong.. I'm tired it's after 4am  :P Use Eval()

 

Here's an example:

 

<?php
$function = 'foobar';
function foobar()
{
echo 'foobar';
}
eval($function . '();');
?>

Link to comment
Share on other sites

Whoops, my fault. I read that wrong.. I'm tired it's after 4am  :P Use Eval()

 

Here's an example:

 

<?php
$function = 'foobar';
function foobar()
{
echo 'foobar';
}
eval($function . '();');
?>

 

 

wow thnx it works thatnk man..god bless!!!

Link to comment
Share on other sites

You don't need to use eval:

 

$POINT = "foobar";
Function foobar($how_bar)
{
    Echo  "not just foobar, $how_bar  foobar.";
}

$POINT('really');

 

However, next time you have a homework question, I suggest you present it as such. People will still help you, as long as you're not after a direct solution.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.