Overwriting built-in functions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Overwriting built-in functions

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Overwriting built-in functions

Post by AbraCadaver »

What do you mean you disabled a function? You disabled an extension that defines this function? What function?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Re: Overwriting built-in functions

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Overwriting built-in functions

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Re: Overwriting built-in functions

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Overwriting built-in functions

Post by Weirdan »

kendall wrote:Soooooo how do you remove it all together?
Not possible unless you recompile php.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Overwriting built-in functions

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: Overwriting built-in functions

Post by JNettles »

Or just rename your function to something else and save yourself a couple of days......
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Overwriting built-in functions

Post 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
User avatar
JNettles
Forum Contributor
Posts: 228
Joined: Mon Oct 05, 2009 4:09 pm

Re: Overwriting built-in functions

Post by JNettles »

And on another server that hasn't deleted a function from the PHP source code.
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: Overwriting built-in functions

Post by manohoo »

... or even easier

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