Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Eval & Writing php variables to a new file

    Hey

    I have built a template html variable:
    $html

    and want to setup some variables within that $html variable so when I write it I can call the php variables from within that file.

    Here is an example of how far I have got:
    PHP Code:
     $html .= "<?php $var1='".$var1."'?>";
     $html .= "<?php $var2='".$var2."'?>";

    ...

     eval("\$html = \"$html\";");
     $fh = fopen($file, 'w');
     fwrite($fh, $html);
     fclose($fh);
    Last edited by adbox; 01-28-2010 at 11:11 PM.

  • #2
    New Coder
    Join Date
    Jul 2008
    Location
    India
    Posts
    39
    Thanks
    0
    Thanked 2 Times in 2 Posts
    You can do that.

    For example -
    <?php
    $string = "beautiful";
    $time = "winter";

    $str = 'This is a $string $time morning!';
    echo $str. "<br />";

    eval("\$str = \"$str\";");
    echo $str;
    ?>

    Refer http://www.w3schools.com/php/func_misc_eval.asp for more detailed info.



  •  

    Posting Permissions

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