如何在 PHP 中使用 file_get_contents 从变量中回显

我正在尝试使用 file_get_contents 回显 .php 文件的内容。

应该从其中回显内容的文件名部分由 sql 查询生成,如下所示:

$property_info = '"include/textfiles/' . $properties['expose_info'] . '_info.php"';

然后我试图做echo file_get_contents($property_info);

出于某种原因,这不起作用,但是如果我正在echo $property_info;输出正确的文件路径,并且当我将该文件路径复制粘贴回 file_get_contents 时,它也会以我想要的方式回显文件内容。

那么不工作的原因是什么echo file_get_contents($property_info);?不允许变量?


慕工程0101907
浏览 144回答 1
1回答

白猪掌柜的

利用$property_info = 'include/textfiles/' . $properties['expose_info'] . '_info.php';不是$property_info = '"include/textfiles/' . $properties['expose_info'] . '_info.php"';原因 :Your $property_info contain double qoute inside single quote
打开App,查看更多内容
随时随地看视频慕课网APP