PHP-获取包含文件中定义的变量

PHP-获取包含文件中定义的变量,php,zend-framework,Php,Zend Framework,关于PHP我有一个非常具体的情况 假设我有以下代码: index.php 这可能会有所帮助(请注意,我刚刚直接添加了include的内容,因此代码可以运行并产生一些结果……在这种情况下,仍然只有include): 在index.php中包含之前和之后的,然后让我们假设other.php包含exec('soemthing bad')如果你不知道php文件中包含的内容,请不要运行php文件。因此,你基本上是想窃取文件,该文件的编码是有原因的。我更新了我的帖子,说明了我的真实原因。该文件来自何方?问作

关于
PHP
我有一个非常具体的情况

假设我有以下代码:

index.php

这可能会有所帮助(请注意,我刚刚直接添加了include的内容,因此代码可以运行并产生一些结果……在这种情况下,仍然只有include):


在index.php中包含
之前和之后的
,然后让我们假设other.php包含
exec('soemthing bad')如果你不知道php文件中包含的内容,请不要运行php文件。因此,你基本上是想窃取文件,该文件的编码是有原因的。我更新了我的帖子,说明了我的真实原因。该文件来自何方?问作者?不要要求我们解码编码文件我们大多数人都是为了生存而编程谢谢你,我更新了我的帖子,告诉你我的真正原因。你的答案非常接近我所需要的,但我认为当包含的文件中有函数结果中的变量赋值时,它并不完全适用。只要变量在包含后可用(即,它们在全局范围内),这应该可以正常工作-值来自何方无关紧要。
<?
$a = "1";
$b = "2";
include("other.php");
$c = "3";
$d = "4";
?>
<?
$x = "11";
$y = "12";
?>
<?php @Zend;
4123;
/* This is not a text file */
print <<<EOM
<html><body><a href="http://www.zend.com/products/zend_guard"><img border="0" src="http://www.zend.com/images/store/safeguard_optimizer_img.gif" align="right"></a><center><h1>Zend Optimizer not installed</h1></center><p>This file was encoded by the <a href="http://www.zend.com/products/zend_guard">Zend Guard</a>. In order to run it, please install the <a href="http://www.zend.com/products/zend_optimizer">Zend Optimizer</a> (available without charge), version 3.0.0 or later. </p><h2>Seeing this message instead of the website you expected?</h2>This means that this webserver is not configured correctly. In order to view this website properly, please contact the website's system administrator/webmaster with the following message:<br><br><tt>The component "Zend Optimizer" is not installed on the Web Server and therefore cannot service encoded files. Please download and install the Zend Optimizer (available without charge) on the Web Server.</tt><br><br><b>Note</b>: Zend Technologies cannot resolve issues related to this message appearing on websites not belonging to <a href="http://www.zend.com">Zend Technologies</a>. <h2>What is the Zend Optimizer?</h2><p>The Zend Optimizer is one of the most popular PHP plugins for performance-improvement, and has been available without charge, since the early days of PHP 4. It improves performance by scanning PHP's intermediate code and passing it through multiple Optimization Passes to replace inefficient code patterns with more efficient code blocks. The replaced code blocks perform exactly the same operations as the original code, only faster. </p><p>In addition to improving performance, the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Guard. </p><p>The Zend Optimizer is a free product available for download from <a href="http://www.zend.com">Zend Technologies</a>. Zend Technologies also developed the PHP scripting engine, known as the <a href="http://www.zend.com/products/zend_engine">Zend Engine</a>.</p></body></html>
EOM;
exit();
__halt_compiler();

2003120702‚–ÛUÕ_Eq7X-‡äÂK.½Iëoôïîuolÿ@f*vÈ9õ]¾2003120702‚–ÛUÕ_Eq7X-‡äÂK.½Iëoôïîuolÿ@f*vÈ9õ]¾2003120702‚–ÛUÕ_Eq7X-‡äÂK.½Iëoôïîuolÿ@f*vÈ9õ]¾2003120702‚–ÛUÕ_Eq7X-‡äÂK.½Iëoôïîuolÿ@f*vÈ9õ]¾
... the code continues ...
<?php

$a = 1;
$b = 2;

$preVars = null; // Define it so it doesn't show up later
$preVars = array_keys(get_defined_vars());

// Normally included, just here for tests sake
$x = 10;
$y = 11;
// End of your include

$postVars = array_keys(get_defined_vars());

$c = 3;
$d = 4;

$diff = array_diff($postVars, $preVars);

echo "New Variables:\n";
foreach($diff as $d)
echo "- \$".$d."\n";
New Variables:
- $x
- $y