[英]Getting variables from file and putting them in a HTML document
I'm trying to write an array in one php file called "post-info.php", which looks like so: 我试图在一个名为“ post-info.php”的php文件中编写一个数组,如下所示:
<?php
$settings = array(
'submitter' => 'tester',
'body' => "How about this:
> Gigabyte Tri-SLI Liquid Luggage 980s",
);
?>
First of all, I want body
to be a multi-line variable. 首先,我希望
body
为多行变量。 Then, I want it to be called by an index.php
file, put through a Markdown parser, and then shown. 然后,我希望它由
index.php
文件调用,放入Markdown解析器,然后显示。 Looks a bit like this: 看起来像这样:
<!DOCTYPE html>
<?php
include 'Parsedown.php';
$postinfo = include 'post-info.php';
$Parsedown = new Parsedown();
?>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="style.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="jumbotron vertical-center">
<blockquote>
<div class="post-body"><?php echo $Parsedown->text($postinfo["body"]); ?></div>
<hr />
<p class="post-submitter"><?php include($postinfo["submitter"]); ?></p>
</blockquote>
</div>
</div>
</body>
</html>
So, how do I get those two variables to show up in those places (no doubt I wrote them wrong) and have the multi-line variable actually show up multi-line? 那么,如何使这两个变量显示在那些位置(毫无疑问我写错了),并让多行变量实际显示多行?
I don't know Parsedown.php
, but for raw php, if you use 我不知道
Parsedown.php
,但对于原始php,如果您使用
include 'post-info.php';
//then you can use your $settings variable defined in post-info.php
echo $Parsedown->text($settings["body"]);
Instead of this 代替这个
<p class="post-submitter"><?php include($postinfo["submitter"]); ?></p>
Try to use this 尝试使用这个
<p class="post-submitter"><?= $settings["submitter"]; ?></p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.