我正在尝试在我的网站上使用 PHP 制作动态标题。我的index.php打开各种客户端页面client.php。在这些客户页面上,希望客户名称显示为页面标题。
我使用以下 PHP 链接打开客户端页面。
<a class="iframe" href="client.php?id=<?php echo $rows['id']; ?>&Client Name=<?php echo $rows['client_name'] ?>">
这是我尝试将客户端名称作为 client.php 上的标题进行继承的方法,但它只是一个空白标题......
<?php $client_name_title = $_GET['Client Name'];?>
<title><?php echo $client_name_title ?></title>
我做错了什么???
最佳答案
您需要通过不带空格的 URL 传递变量,如下所示:
<a class="iframe" href="client.php?id=<?php echo $rows['id']; ?>&client_name=<?php echo $rows['client_name'] ?>">
<?php
if(isset($_GET['client_name'])){
$client_name_title = $_GET['client_name'];
} else {
//client not set, revert to default behavior
}
?>
关于PHP 网站标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36492110/