[xdebug-general] Re: excluding code or variables possible?

From: Derick Rethans <derick[@]xdebug.org>
Date: Mon, 25 Jun 2012 19:36:21 +0200 (CEST)

On Mon, 25 Jun 2012, Werner Flamme wrote:

> Is there a chance that I can read the source code of a function just
> by invoking PHP methods, right out of memory, because I do not know
> the file name and directory of the code? Or do I have to include a
> file manager in the code, tap through every directory, open every PHP
> source file?

Quite easily:

<?php
$r = new ReflectionFunction('secret');
$f = file($r->getFileName());
var_dump(array_slice($f, $r->getStartLine(), $r->getEndLine() - $r->getStartLine() ) );
?>

cheers,
Derick

-- 
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
Xdebug | http://xdebug.org | xdebug-general@lists.xdebug.org
twitter: @derickr and @xdebug
Received on Mon Jun 25 2012 - 18:36:22 BST

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST