简体   繁体   English

如何使用PHP Include更改HTML元素的内容

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

I basically have a php header like this 我基本上有这样的php标头

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

That is contained in a header.php file, but when I'm on another page for example 它包含在header.php文件中,但是例如当我在另一个页面上时

<?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. 我该怎么做,以便您可以在目标网页的header.php中更改h1标题。 I have tried putting in the h1 in the header, and then putting on the destination page, but this hasn't worked for me. 我尝试将h1放在标题中,然后放入目标页面,但这对我没有用。 Is there any way to simplify do this. 有什么方法可以简化此操作。

I think this is what you are asking: 我想这就是您要问的:

header.php: header.php:

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

other page 其他页面

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM