tags:

views:

28

answers:

1

Background: PHP allows providers to disable functions (directive "disable_functions"). So in order to get to know if your project is running on a specific server you'll have to check:

  1. What built-in (=excluding user-defined) functions is your to-be-deployed project using?
  2. Are the functions available on the specific host?

(Question (2) is a trivial loop over the result (1) with function_exists.)

In order to get the harvesting working (=a mostly complete set of built-in functions used on the development servers) one could create a list of functions with get_loaded_extensions(), get_extension_funcs() and get_defined_functions() (and access it's 'internal' array for the built-in functions).

Now the question: How would you extract/grep the built-in PHP functions used in the project from your (possibly hundreds of) source files?

It could be a nice PERL job or somethig like that. How would you do it?

+1  A: 

The PHP tokenizer - namely token_get_all() - is probably the most reliable tool for this, as it uses the same parsing mechanism the PHP interpreter itself does.

If you're looking for a Perl based solution, phpxref has a function to tell all used built in functions: Random example here.

Pekka
Nice hints, i've got to take a look at the code.
initall