Announcement

Collapse
No announcement yet.

Want to output variable contents in htm file from php file, how?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Riklund
    replied
    something like this..

    This is one way:
    PHP Code:
    // load the .htm file
    $fp fopen('template.htm','r');
    $html fread($fpfilesize('template.htm'));
    fclose($fp);

    // replace the data
    $html str_replace( array('{make}','{model}','{year}'), array($make,$model,$year), $html);

    // print it
    echo $html
    You can also use a template engine like Smarty.

    Leave a comment:


  • Want to output variable contents in htm file from php file, how?

    I have a PHP file. No MYSQL database. I'd like to have it open an .htm file and output the results in the php file to the .htm template.

    So, for example say there is a bunch of variables called:

    $make
    $model
    $year

    I want to open a .htm file and output the contents of $make, $model & $year in the htm format using variables in the htm itself. ie. {make} {model} {year} and it would import the contents of each into the corresponding tag.

    How can this be achieved?

    Thanks
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X