Code: Select all
<!--#include virtual="header.php" -->
<!--#include virtual="include.php?var=example" -->
<!--#include virtual="footer.php" -->
Code: Select all
<!--#include virtual="footer.php?var=example" -->Moderator: General Moderators
Code: Select all
<!--#include virtual="header.php" -->
<!--#include virtual="include.php?var=example" -->
<!--#include virtual="footer.php" -->
Code: Select all
<!--#include virtual="footer.php?var=example" -->I think that syntax is for Server Side Includes. That is the web server merging that file into the output. To do a PHP include the syntax would be:leewad wrote:I`m wanting to pass the text 'example' to the footer.php file, i have tried sessions but cant get this to work any ideas to how i can pass the variable to footer.php without adding it to the actual footer code i.eAs i dont want to be changing all the filesCode: Select all
<!--#include virtual="footer.php?var=example" -->
Code: Select all
<?php
$var = 'example';
include "footer.php";
?>Code: Select all
$var="example text";
include "footer.php";
Code: Select all
if(isset($var)) echo "Your text passed to me is: ".$var."\n";PHP files can mix PHP and HTMLleewad wrote:Yes in a php file but I'm wanting HTML
Code: Select all
<h1> HTML HERE</h1>
<p>This html is boring</p>
<?PHP
if(isset($var)) echo "<p>Value passed HTML: ".$var."</p>";
?>
<p>And more html</p>
Code: Select all
<!--#include virtual="header.php" -->
<!--#include virtual="file_b.php?var=hello" -->
<!--#include virtual="footer.php" -->
PHP.leewad wrote:why what METHOD would you do it?
Code: Select all
<!--#include virtual="footer.php?var=hello" -->that you don't want to modify by hand. Then you should learn some command line tools like unix's sed to search and replace the section of code you need to modify.leewad wrote:I have 100's of html files with some code
Code: Select all
<!--#set var="myvar" value="myvalue" -->Code: Select all
$_SERVER['myvar']Did the client want the files to not contain PHP, or did the client want ".html" to appear in the browser's address bar? If it's the latter, it is possible to tell Apache Server to parse PHP files having a .html extension by using the SetHandler or AddHandler directive.leewad wrote:The client only wanted html files
Code: Select all
<FilesMatch "\.html$">
SetHandler application/x-httpd-php
</FilesMatch>Code: Select all
AddHandler application/x-httpd-php .html