Re: sending variable to include file
- From: Chuck Anderson <websiteaddress@xxxxxxxxx>
- Date: Fri, 18 Aug 2006 12:44:07 -0600
vetchling wrote:
Hi, I'm pretty new to php but I've been working on a site and have aYou don't need to pass a variable to an included file, it already has access to all variables in the includING script. It becomes part of the script that is including it.
problem I can't fix, though it's probably pretty simple.
Basically I have an index.php file that includes a header.php file. I
attempt to pass a variable to it as follows:
<?include("header.php?page=Home");?>
Then the header.php file contains this code:
<?php
$page = $_GET['page'];
?>
<html><head><title><?$page?></title>
I want $page to contain the string "Home" of course, but it ends up
being nothing but an empty string.
Thanks in advance for your help.
Matt
$page = 'Home';
include 'header.php';
Now header.php will see that $page contains 'Home'.
--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
*****************************
.
- References:
- sending variable to include file
- From: vetchling
- sending variable to include file
- Prev by Date: Re: $txt line
- Next by Date: Re: PHP Redirect Problem
- Previous by thread: Re: sending variable to include file
- Next by thread: keystone php3 app log and pastebins trying get rid of errors on php 4.3.9 on redhat linux httpd 2.0.52
- Index(es):
Relevant Pages
|