Click to See Complete Forum and Search --> : replace function with regular expressions


Sid3335
03-19-2007, 04:16 AM
i'm reading in the contents of a php file and storing it in a string.

i would like to wrap some text around every function that is in the string.


if (!function_exists(FUNCTION_NAME))
{
//function goes here
}


so i need to wrap that text around it and get the name of the function to put in the paramter list for the function_exists().

Any help is appreciated

bokeh
03-19-2007, 11:36 AM
If you are considering this you need to concentrate on what has gone wrong with your logic to make it necessary.

Sid3335
03-19-2007, 11:50 AM
yeah i see your point.

At work we are playing php golf, and i need to time peoples scripts through 500 iterations and i thought that a quick and dirty method would just be to check if the functions exists first, rather than have to edit them all by hand.

I was looking at php reflections, and i suppose the correct way would be to lift the whole function out and place it before the loop so it doesn't get included each time.

any help or other suggestions are apreciated.

Thanks guys

bokeh
03-19-2007, 11:56 AM
Just use require_once() for the file that contains the functions.