[英]How to echo from a variable using file_get_contents in PHP
I am trying to echo the contents of a .php file using file_get_contents.我正在尝试使用 file_get_contents 回显 .php 文件的内容。
The filename of which the content is supposed to be echoed from is generated partly by a sql query as below:内容应该从其回显的文件名部分由 sql 查询生成,如下所示:
$property_info = '"include/textfiles/' . $properties['expose_info'] . '_info.php"';
I am then trying to do echo file_get_contents($property_info);
然后我试图做
echo file_get_contents($property_info);
For some reason this is not working, but if i'm doing echo $property_info;
出于某种原因,这不起作用,但如果我在做
echo $property_info;
it is outputting the correct file path and when i copy paste that file path back into file_get_contents its also echoing the file contents just how i want it.它正在输出正确的文件路径,当我将该文件路径复制粘贴回 file_get_contents 时,它也以我想要的方式回显文件内容。
So whats the reason for echo file_get_contents($property_info);
那么
echo file_get_contents($property_info);
的原因是什么echo file_get_contents($property_info);
not working?不工作? No variables allowed?
不允许变量?
Use用
$property_info = 'include/textfiles/' . $properties['expose_info'] . '_info.php';
Not不是
$property_info = '"include/textfiles/' . $properties['expose_info'] . '_info.php"';
Reason :原因 :
Your $property_info contain double qoute inside single quote
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.