Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$variables question

Status
Not open for further replies.

mettodog

Vendor
Jul 11, 2000
94
US
this is what i want to do:

$str_box_body = "require ('common/login.php')"

of course, this produces a parse error.

How can i make this work?
 
I just made a file test.php with the following:

<?
$str_box_body = &quot;require ('common/login.php')&quot;;
echo $str_box_body;
?>

and it did output: require ('common/login.php')

Are you tring to just assin the string &quot;require ('common/login.php')&quot; to the variable $str_box_body? If so then that should work. The only possible thing I could see wrong with your example above is a missing semi-colan at the end.
 
no, i dont want to assign it as a string, i want php to actually parse that line of code.
 
Code:
$str_box_body = &quot;require(\&quot;common/login.php\&quot;);&quot;;

eval($str_box_body);

eval() is a command that evaluates an expression or variable *as* PHP code and then runs the results.
 
In that case you could just put in:
require (&quot;common/login.php&quot;);

If that line of code is included conditionaly then I would use the include() command:
if (conditional statemen) include (&quot;common/login.php&quot;);

I have never used the eval() command, but I could see where it would be handy if you had the same file included/required several times through out a application.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top