[英]Echo out php contents
I was wondering if functions like file_get_contents
and file_put_contents
exist except they grab the raw PHP code too. 我想知道是否存在诸如file_get_contents
和file_put_contents
类的函数,但是它们也捕获原始的PHP代码。 All the files are local so I assume something would exist for this. 所有文件都是本地文件,因此我认为这将存在。 The only other solution I thought of for this was using the FTP library. 我想到的唯一其他解决方案是使用FTP库。 If anyone knows a way around this please let me know! 如果有人知道解决方法,请告诉我! Thanks. 谢谢。
Example: 例:
code.php code.php
<?php
echo 'hello world';
text.php text.php
<textarea>
<?php
echo file_get_contents('code.php');
?>
</textarea>
Should output: 应该输出:
<textarea>
<?php
echo 'hello world'; //isn't actually executed, just displayed as raw text
</textarea>
您需要转义HTML字符:
echo htmlentities( file_get_contents('code.php') );
In your above example this would work: 在上面的示例中,这可以工作:
code.php code.php
<?php
echo 'hello world';
text.php text.php
<textarea>
<?php include('code.php'); ?>
</textarea>
only a test not a answer (will be deleted) 仅测试而不是答案(将被删除)
index.php 的index.php
<textarea rows="10">
<?php
echo file_get_contents('code.php');
?>
</textarea>
code.php code.php
<?php
echo 'hello world';
echo 'textline 3';
output 产量
IE8 IE8
show sourcetext IE8 显示源文本IE8
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.