$precontent .= "
$precontent .= "
我一直在尝试通过将我的网站结构定义为 php 字符串变量然后回显这些变量来清理我的网站。这将我的所有站点结构压缩为五行,并在 echo 语句之间插入一篇文章。我的页面如下所示:
包含('模块/moddefault.php'); //链接到设置为变量的站点结构
$title = "示例页面"; // 定义页面标题。这被插入到嵌入的标题语句中。回显“$modtop”; // 声明、标题、标题等
回显“$precontent”; // 预内容结构
?>此处显示网页内容
文章内容会很好并且整洁。
?>
我想知道如何将 CSS 嵌入到 PHP 字符串变量中。 PHP 包含不注册,因为 php 已经处理了该页面。 include 语句被打印到我的屏幕上,而不是作为 php 语句进行处理。
以下是我在上一个代码块中回显的变量之一的示例:
$precontent = "";
$precontent .= "";
$precontent .= "";";
$precontent .= "";";
$precontent .= "包含'modules/header.inc'"; //这就是我遇到麻烦的地方
$precontent .= "
$precontent .= "
$precontent .= " ";
$precontent .= "";
$precontent .= "";
$precontent .= "";
$precontent .= "";
我尝试在字符串中嵌入另一个 php 语句,
$precontent .= ""; 这不起作用。
我也尝试过 ssi 格式,但 php 似乎忽略这些语句,因为它们是写在忽略语句内的。
任何帮助都会很棒。
I've been trying to clean up my site by defining my site structure as php string variables and then echoing those variables out. This condenses all of my site structure down to five lines with an article in between the echo statements. My page looks like this:
<?php
include('modules/moddefault.php'); //Link to site structure set as variables
$title = "Example Page"; // Define page title. This is inserted into the embedded title statement.echo "$modtop"; // Declaration, head, title etc.
echo "$precontent"; // Pre-Content Structure
?><h1>Web Content Goes Here</h1>
<p>Article content will be nice and uncluttered.</p><?php
echo "$postcontent"; // Post-Content Structure
?>
I'm wondering how I can embed my CSS includes inside of a PHP string variable. PHP includes don't register because the php has already processed the page. The include statements are being printed to my screen instead of getting processed as a php statement.
Here is a sample of one of the variables I echo in the previous code block:
$precontent = "<body>";
$precontent .= "<div id='wrapper'>";
$precontent .= "<div id='header'>";
$precontent .= "<div>";
$precontent .= "include 'modules/header.inc'"; //THIS IS WHERE I'M HAVING TROUBLE
$precontent .= "</div>";
$precontent .= "</div>";
$precontent .= "<div id='navtop'>";
$precontent .= "<div>";
$precontent .= "include('modules/topnav.inc');"; // THIS IS WHERE I'M HAVING TROUBLE
$precontent .= "</div>";
$precontent .= "</div>";
$precontent .= "<div id='centerbox'>";
$precontent .= "<div id='article'>";
$precontent .= "<div id='innerarticle'>";
$precontent .= "<div>";
I tried embedding another php statement within the string,
$precontent .= "<?php include('modules/topnav.inc';?>";
This didn't work.
I have also tried ssi format, but php seems to ignore those statements because they are written inside an ignore statement.
Any help would be great.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
您尝试过
$precontent.=file_get_contents('modules/header.inc');
have you tried
$precontent.=file_get_contents('modules/header.inc');
为什么不拥有类似的东西:
然后
你就会有
Why not having something like:
and
and then you'd have