Reputation: 2032
In PHP how do I change the variable of a different page.
For example:
header.php
// For style-specific pages.
echo $header_styles;
Then in a page like, index.php:
include('header.php');
echo $header_styles = "<style></style>";
I used to know how to do this, but I completely forgot.
Upvotes: 0
Views: 232
Reputation: 251
You need to do that first:
In your header.php you will have:
<?php
echo $header_styles;
?>
Then in a page that you need to include the header, like index.php you will have:
<?php
$header_styles = "<style></style>";
include('header.php');
?>
<html>
Your html code here
</html>
You need to change the name from index.html to index.php. Then you need to set the variable before to call header.php and then you will do the "echo" to that. Do not apply the echo when you are setting the value, because I think you do not want to print that you need only to set the value.
Upvotes: 1