2012-08-02 55 views
1

基本上,我需要在包含後查看文件的PHP代碼。我正在試圖正確地看到PHP代碼運行的是什麼。如...查看包含的PHP代碼

<?php // a.php 
    $a = 10; 
?> 

<?php // b.php 
    include('a.php'); 
    $b = 20; 
?> 

如果我試圖讓b.php的代碼,它會顯示如下:

<?php 
    $a = 10; 
    $b = 20; 
?> 

這可能嗎?如果是這樣,怎麼樣?

+0

你想用這個完成什麼? – 2012-08-02 02:19:18

+0

不確定我是否滿足您的需求 - 您是否可以不按照它們包含的順序查看包含文件的內容? – 2012-08-02 02:19:29

+0

快速搜索獲得[pp4php](http://www.monperrus.net/martin/pp4php),看起來它可能會做你所需要的。 – nickb 2012-08-02 02:19:51

回答

3
// at the end of your script 
<?php 
$totalRunCode = ''; 
$scripts = get_included_files(); 
foreach($scripts as $script) 
{ 
    $totalRunCode .= file_get_contents($script); 
} 

// do whatever with totalRunCode 

雖然我不知道你爲什麼要這樣做。

+1

這並不容易。想象一下,如果(假)包含'文件';'代碼 – zerkms 2012-08-02 02:22:50

+0

謝謝Lusitanian,那很完美! :) – Shane 2012-08-02 02:34:43