Is this possible at all?
I'd like to adjust the <title> and other things according to variables contained in the called file but I obviously have to have those before I call the file. Is there anyway to do this?
Using variables before you include the file the variable is in
No. The scope of PHP says that the only variables you can use are those that are within the $GLOBAL scope (like $POST, $GET, $SESSION, $COOKIE) and which you define within the script.
If you want to include those variables & their values, just include the file; however, you could store them in a session. But it would just be easier to include the file.
Why would you want to use variables before they are defined? It's like driving on a bridge before it's completed.... well not really...crap.... another failed metaphor....
~Brett
I basically want to do this
<h2>$title</h2>
include("filewith$titlein.php");
so that the title changes depending on what file I'm including
reverse the lines, works perfectly!!
include("filewith$titlein.php");
echo '<h2>'.$title.'</h2>';
~Brett
bpat1434 wrote:reverse the lines, works perfectly!!
include("filewith$titlein.php"); echo '<h2>'.$title.'</h2>';
~Brett
But then I end up with the header below the content, when I really need it above. And I still won't be able to use $title in <title></title>
You need to rethink where you declare the variables then.