[英]How to echo from a variable using file_get_contents in PHP
我正在尝试使用 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);
的原因是什么echo file_get_contents($property_info);
不工作? 不允许变量?
用
$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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.