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.
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.