Results 1 to 2 of 2

Thread: evaluating code with variables

  1. #1
    Join Date
    Nov 2002

    evaluating code with variables

    if have a variable in your script, and in that variable is other variables, then when you set that variable then echo it, the values are there. The first variable is evaluated when set. Example:
    $var1 = "test";
    $var2 = "this is a $var1";
    echo $var2;

    gives you "this is a test"

    OK, that is the setup. Now the issue is that $var2 is a file (let's call it var2.file). So I want to put the file contents into $var2 and have it evaluated. But I do not want to echo it until later based on other things.
    Last edited by Beach Bum; 11-08-2005 at 07:46 PM.

  2. #2
    Join Date
    Nov 2002
    OK - got it - using my real variable names here it is:

    PHP Code:
    $header htmlspecialchars(file_get_contents('../restricted/header.htm'));
    "\$header = \"$header\";");
    // $header = htmlspecialchars_decode($header);   // php5 or use below code
    $header preg_replace('/&lt;/','<',$header);
    $header preg_replace('/&gt;/','>',$header);
    $header preg_replace('/&quot;/','"',$header);
    $header preg_replace("/'/","'",$header); 
    EDIT >> The post converted the ' character in the last preg_replace, but you get the idea.
    Last edited by Beach Bum; 11-08-2005 at 08:16 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles