EchoFool Posted March 25, 2010 Share Posted March 25, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196441-edit-pre-built-in-functions/ Share on other sites More sharing options...
Gighalen Posted March 25, 2010 Share Posted March 25, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196441-edit-pre-built-in-functions/#findComment-1031426 Share on other sites More sharing options...
litebearer Posted March 25, 2010 Share Posted March 25, 2010 The easy to find out is... use the existing function name but have it do something really simple like, oh gee, "Hello World". The test should give you your answer Quote Link to comment https://forums.phpfreaks.com/topic/196441-edit-pre-built-in-functions/#findComment-1031428 Share on other sites More sharing options...
oni-kun Posted March 25, 2010 Share Posted March 25, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196441-edit-pre-built-in-functions/#findComment-1031432 Share on other sites More sharing options...
EchoFool Posted March 26, 2010 Author Share Posted March 26, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196441-edit-pre-built-in-functions/#findComment-1032040 Share on other sites More sharing options...
oni-kun Posted March 26, 2010 Share Posted March 26, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196441-edit-pre-built-in-functions/#findComment-1032044 Share on other sites More sharing options...
trq Posted March 26, 2010 Share Posted March 26, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/196441-edit-pre-built-in-functions/#findComment-1032045 Share on other sites More sharing options...
oni-kun Posted March 26, 2010 Share Posted March 26, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/196441-edit-pre-built-in-functions/#findComment-1032048 Share on other sites More sharing options...
EchoFool Posted April 2, 2010 Author Share Posted April 2, 2010 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/196441-edit-pre-built-in-functions/#findComment-1035577 Share on other sites More sharing options...
trq Posted April 2, 2010 Share Posted April 2, 2010 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' {} \; Quote Link to comment https://forums.phpfreaks.com/topic/196441-edit-pre-built-in-functions/#findComment-1035582 Share on other sites More sharing options...
EchoFool Posted April 2, 2010 Author Share Posted April 2, 2010 Did not know i could make a script to edit words thatll be handy! Ill read up on it. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/196441-edit-pre-built-in-functions/#findComment-1035583 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.