我试图在Parsedown中使用减价额外 (以前从未使用过)。我有代码$_GET所选类别(?cat=0),并将其路径&文件名设置为var。它的$_GET页面号很好,但是当我设置文件var时,它只是打印到屏幕上,而不加载我的页面。
//sets the page (category) number for use with array
//also sets the path to the category's pages
if (isset($_GET['cat'])) {
$catNum = $_GET['cat'];
$catPath = 'content/' . $pageList[$catNum]['path'];
echo '<div class="center pageNav">';
//lists out subpages of catagory
$pageAmt = count($pageList[$catNum]['pages']);
for ($i = 0; $i < $pageAmt; $i++) {
echo '<a href="' . $catPath . $pageList[$catNum]['pages'][$i]['file'] . '">' . $pageList[$catNum]['pages'][$i]['title'] . '</a>';
};
echo '</div>';
//sets path & filename var to selected page: this is the part where it prints the var and doesn't run the rest. The var is pointing to the right file, I checked.
$page = $catPath . $pageList[$catNum]['mainPage'];
} else {
$page = 'content/home.md';
};
//parsedown
require 'parsedown/parsedown.php';
require 'parsedown/parsedownextra.php';
echo ParsedownExtra::instance()
->setBreaksEnabled(true)
->setMarkupEscaped(true)
->text($page);发布于 2015-12-19 00:40:58
Parsedown获取标记文本并呈现它。在您的示例中,您将$page (包含字符串,文件名)传递给->text($page)。这会将字符串解析为标记文本,并呈现出来。所以,在你的例子中,你会看到它到底在做什么。如果您试图通过->text运行文件文本,则需要先加载文件内容并传递给Parsedown。
发布于 2015-12-17 18:46:14
在if语句的末尾有一个分号。
} else {
$page = 'content/home.md';
}; <--https://stackoverflow.com/questions/34341936
复制相似问题