Page 1 of 1

Overwriting built-in functions

Posted: Tue Dec 29, 2009 11:58 am
by kendall
Hello,

I disabled a built-in function in my PHP.ini file in order to create my own custom function of the same name. But I get the error "Cannot redeclare function". How can this be if I have disabled the built-in function?

I don't have PECL

Re: Overwriting built-in functions

Posted: Tue Dec 29, 2009 12:21 pm
by AbraCadaver
What do you mean you disabled a function? You disabled an extension that defines this function? What function?

Re: Overwriting built-in functions

Posted: Tue Dec 29, 2009 1:10 pm
by kendall
AbraCadaver wrote:What do you mean you disabled a function? You disabled an extension that defines this function? What function?
i disable_functions = mime_content_type

Re: Overwriting built-in functions

Posted: Tue Dec 29, 2009 1:22 pm
by AbraCadaver
kendall wrote:
AbraCadaver wrote:What do you mean you disabled a function? You disabled an extension that defines this function? What function?
i disable_functions = mime_content_type
That just disables their use. The function is still defined.

Re: Overwriting built-in functions

Posted: Tue Dec 29, 2009 2:01 pm
by kendall
AbraCadaver wrote:
That just disables their use. The function is still defined.
Soooooo how do you remove it all together? the manual says its deprecated.

Re: Overwriting built-in functions

Posted: Tue Dec 29, 2009 2:08 pm
by Weirdan
kendall wrote:Soooooo how do you remove it all together?
Not possible unless you recompile php.

Re: Overwriting built-in functions

Posted: Tue Dec 29, 2009 2:10 pm
by AbraCadaver
It's deprecated in 5.3 which I think your going to need to use the fileinfo extension. It probably won't be removed until PHP 6. To remove it yourself you would need to find it in the PHP source code, comment it out and compile PHP yourself.

Re: Overwriting built-in functions

Posted: Tue Dec 29, 2009 3:03 pm
by JNettles
Or just rename your function to something else and save yourself a couple of days......

Re: Overwriting built-in functions

Posted: Tue Dec 29, 2009 9:25 pm
by josh
Yeah, in this situation I would usually create a class just to wrap the function, that way it will be easy to change in the future

Re: Overwriting built-in functions

Posted: Wed Dec 30, 2009 9:48 am
by JNettles
And on another server that hasn't deleted a function from the PHP source code.

Re: Overwriting built-in functions

Posted: Wed Dec 30, 2009 11:54 am
by manohoo
... or even easier

Why don't you rename your function to something else?