Jump to content

What are the advantages of using eval()?


11Tami

Recommended Posts

it will evaluate a string as a string, and it will not as an executable string. variables will not be used as variables.
[code]
<?php
$string = 'cup';
$name = 'coffee';
$str = 'This is a $string with my $name in it.';
echo $str. "\n";
eval("\$str = \"$str\";");
echo $str. "\n";
?> [/code]

Output:
This is a $string with my $name in it.
This is a cup with my coffee in it.
Link to comment
Share on other sites

Thanks but can you make it more simple for someone who doesn't do scripting all the time? I have no clue what you just said. I know there are many types of strings. I don't see a difference between a string and an executable string.  I believe these are variables $ but everything I saw said eval can use variables. So I don't understand your description. Please explain the difference someone and explain it like your are talking to someone in high school who hasn't done much scripting? Thank you very much.
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.