Shane
Shane

Reputation: 2047

View PHP code after includes

Basically, I need to view the PHP code of a file, after includes. I am trying to see EXACTLY what PHP code is run. eg...

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

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

If I was trying to get the code of b.php, it would display the following:

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

Is that possible? If so, how?

Upvotes: 1

Views: 226

Answers (1)

Lusitanian
Lusitanian

Reputation: 11122

// 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

Though I don't know why you'd want to do this.

Upvotes: 3

Related Questions