【发布时间】:2015-06-13 14:24:31
【问题描述】:
出于教育目的,我想回显 php 代码本身。这可能吗?同时我还需要将代码作为php代码来执行。
将 html special-chars 添加到此:
$this->art = file_get_contents("$this->Mainpage/$this->dir/$this->article");
变成:
$this->Art = htmlspecialchars( file_get_contents("$this->Mainpage/$this->dir/$this->Artikel"));
但这仍然不会输出代码本身,因为 php 解释器似乎掌握了代码并直接解释它。 htmlspecialchars () 只对html代码有影响,你可以看到括号里的文章。
我还尝试使用 .html 文件而不是 .php 文件。但是即使您将其重命名为.jpeg,PHP 也会对其进行解释。
我已经束手无策了。我将不胜感激。提前致谢。
【问题讨论】:
-
file_get_contents不解释任何 PHP,这里还有其他事情发生。有问题的文件中究竟有什么? -
你实际上是如何回显代码的?
-
只需这样做
str_replace('<?php','',$yourdata); -
$this->Art = file_get_contents("$this->Mainpage/$this->dir/$this->Artikel"); $this->section = explode("End_Embed", $this->Art); $this->Meta_Text=$this->section[0]; $this->content=$this->section[1];echo ("$this->content");
-
但我会试试 Feroz 的代码。谢谢你。只是试图掌握 php 内部发生的事情。
标签: php