这些行导致语法/解析错误,我不知道如何修复它。我很确定它是<?php
和?>
标签,还是单引号。有什么想法吗?
$data = '<?php
$title = "'. $name. '";
$keywords = "'. $title. ','. $developer. '";
$description = "How to install '. $title. ' for PC and Mac.";
include('templates/modheader.php');
include('templates/modfooter.php');
?>';
提前致谢。
答案 0 :(得分:3)
include('templates/modheader.php');
include('templates/modfooter.php');
是罪魁祸首:你混合单引号。完全使用
include("templates/modheader.php");
include("templates/modfooter.php");
答案 1 :(得分:0)
include('templates/modheader.php');
include('templates/modfooter.php');
应该是
include("templates/modheader.php");
include("templates/modfooter.php");
答案 2 :(得分:0)
对于大块字符串数据,我强烈推荐使用HEREDOC
/ NOWDOC
语法。您可以将其与sprintf
组合以注入值
$template = <<<'_PHP'
<?php
$title = '%s';
$keywords = $title . ',%s';
$description = "How to install $title for PC and Mac.";
include 'templates/modheader.php';
include 'templates/modfooter.php';
?>
_PHP;
$data = sprintf($template, $name, $developer);