为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

PHP
慕工程0101907 2022-10-14 15:37:22
我正在尝试使用 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);?不允许变量?
查看完整描述

1 回答

?
白猪掌柜的

TA贡献1893条经验 获得超10个赞

利用

$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


查看完整回答
反对 回复 2022-10-14
  • 1 回答
  • 0 关注
  • 135 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号