user3916382
user3916382

Reputation:

How Can I Change The Content Of HTML Element Using PHP Include

I basically have a php header like this

<body>
<h1>Title</h1>
</body>

That is contained in a header.php file, but when I'm on another page for example

<?php include(header.php) ?>

How would I make it so that you could change the h1 Title in the header.php on the destination webpage. I have tried putting in the h1 in the header, and then putting on the destination page, but this hasn't worked for me. Is there any way to simplify do this.

Upvotes: 0

Views: 139

Answers (1)

user557846
user557846

Reputation:

I think this is what you are asking:

header.php:

<body>
<h1><?php echo $title;?></h1>
</body>

other page

<?php 
$title ='fish';
include('header.php');
?>

Upvotes: 2

Related Questions