Jump to content

Edit pre-built in functions


EchoFool

Recommended Posts

Hey,

 

If i make a function named "function mysql_error()" Will php allow me ?

 

Because mysql_error is already set up as default will it not allow me to use it or will it use my function over the pre-default one ?

 

OR can i just find a way to edit mysql_error() as that would save me editing alot of scripts.

Link to comment
Share on other sites

I'm not exactly sure how functions will behave if you create one that already exists, but I can tell you that you can create functions in older PHP versions that are used by newer PHP functions to achieve the same result. In example, the realpath_cache_size() function was added in PHP 5 but you can create a function in PHP 4 with that name to create a function that does the same that it would do in PHP 5 - or does something completely different. Hope this helps.

Link to comment
Share on other sites

Hey,

 

If i make a function named "function mysql_error()" Will php allow me ?

 

Because mysql_error is already set up as default will it not allow me to use it or will it use my function over the pre-default one ?

 

OR can i just find a way to edit mysql_error() as that would save me editing alot of scripts.

 

APC, or source, but it is highly discouraged. Why on earth would you do this. It's the antichrist of portability.

Link to comment
Share on other sites

Because my alternative is to go through thousands of lines of codes and hundreads of scripts and replace mysql_error to my own custom function and that is going to take weeks.

 

I still fail to see a real scenario in which this would be needed.

Link to comment
Share on other sites

Because my alternative is to go through thousands of lines of codes and hundreads of scripts and replace mysql_error to my own custom function and that is going to take weeks.

 

Have yo not heard of search and replace?

Link to comment
Share on other sites

Because my alternative is to go through thousands of lines of codes and hundreads of scripts and replace mysql_error to my own custom function and that is going to take weeks.

 

Have yo not heard of search and replace?

 

I was going to mention grep/sed, but I thought I'd get lashed.

Link to comment
Share on other sites

Because my alternative is to go through thousands of lines of codes and hundreads of scripts and replace mysql_error to my own custom function and that is going to take weeks.

 

 

Have yo not heard of search and replace?

 

With a script :S ?

Link to comment
Share on other sites

Or with your ide if your using a decent one.

 

On Linux the command could be as simple as something like (not tested)....

 

find /path/to/php/files -name '*.php' -exec sed -i -e 's/mysql_error/custom_error_function/g' {} \;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.