问题
index.php
<?php
$title = "This is the page title";
require_once '/includes/header.php';
?>
header.php
<head>
<title><?= $title ?></title>
</head>
Output
回答1:
I think short tags may not be enabled. Try:
<title><?php echo $title ?></title>
instead
回答2:
did you enable short tags in php.ini?
short link
回答3:
My only thought is that you have short tags disabled in your php.ini.
Try the following:
<head>
<title><?php echo $title; ?></title>
</head>
回答4:
You need to configure your PHP for short_open_tag
来源:https://stackoverflow.com/questions/5930466/passing-variable-to-an-include