1

Are there any way for me to use PHP to parse information of a PHP file, something likes : what functions/classes it has, which functions are built-in/user-defined or how many variables are there....?

1
  • 1
    More useful than just the raw token stream is a parser class like pear.php.net/package/PHP_Parser (or even CodeSniffer) which deciphers defined functions/variables. Commented Mar 13, 2011 at 2:34

1 Answer 1

3

You can use the function token_get_all() to parse PHP source.

$source = file_get_contents('my-file.php');
$tokens = token_get_all($source);
Sign up to request clarification or add additional context in comments.

1 Comment

There was also some discussion about this here: stackoverflow.com/questions/5068007/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.