我对PHP相当陌生。我试图让我的代码基于get属性"pgid“的内容读取Markdown文件的内容,然后输出它。这是:
print Parsedown::instance()->text("Testing *Markdown* with **Parsedown**")产出结果
用
Parsedown测试标记
但这一点:
print (Parsedown::instance()->text(readfile("./".$_GET['pgid'].".md")));在?pgid=about和about.md的内容为Testing *Markdown* with **Parsedown**的情况下,输出为
测试*标记*带**解析** 39
我不知道为什么我可以让所有的部分分开工作,但不能在一起。
发布于 2020-05-04 10:58:04
PHP的readfile()不返回文件内容,而是输出它们。
您的代码所做的,基本上是:
print readfile($filename); // The print() here is implied by readfile itself.
print (Parsedown::instance()->text(80));其中80是从文件中读取的字节数。
而不是readfile(),您可能希望使用file_get_contents(),它确实返回文件的内容。
https://stackoverflow.com/questions/61590505
复制相似问题