acctman Posted June 11, 2009 Share Posted June 11, 2009 is it possible to set multiple names for a function? something like this... would that work? or does each function have to be separate function test1($blah), test2($blah) { do something } [/php Quote Link to comment https://forums.phpfreaks.com/topic/161845-solved-multiple-function-names/ Share on other sites More sharing options...
will35010 Posted June 11, 2009 Share Posted June 11, 2009 I don't know if it will, but I doubt it. You could either use one name or copy the function and just rename the copy. Quote Link to comment https://forums.phpfreaks.com/topic/161845-solved-multiple-function-names/#findComment-853883 Share on other sites More sharing options...
J.Daniels Posted June 11, 2009 Share Posted June 11, 2009 I'm not sure why you would need to do this, but you can have the second function call the first: function test1($blah) { ... } function test2($blah) { return test1($blah); } Quote Link to comment https://forums.phpfreaks.com/topic/161845-solved-multiple-function-names/#findComment-853889 Share on other sites More sharing options...
wildteen88 Posted June 11, 2009 Share Posted June 11, 2009 something like this... would that work? or does each function have to be separate function test1($blah), test2($blah) { do something } Why would you define two functions that did the same thing? That makes no sense at all. Quote Link to comment https://forums.phpfreaks.com/topic/161845-solved-multiple-function-names/#findComment-853897 Share on other sites More sharing options...
acctman Posted June 11, 2009 Author Share Posted June 11, 2009 something like this... would that work? or does each function have to be separate function test1($blah), test2($blah) { do something } Why would you define two functions that did the same thing? That makes no sense at all. i have a script of function that is used on multiple site. to avoid conflicts and going through multiple files renaming functions I thought it would just be easier to have a function with multiple names Quote Link to comment https://forums.phpfreaks.com/topic/161845-solved-multiple-function-names/#findComment-853931 Share on other sites More sharing options...
Maq Posted June 11, 2009 Share Posted June 11, 2009 i have a script of function that is used on multiple site. to avoid conflicts and going through multiple files renaming functions I thought it would just be easier to have a function with multiple names I would assume the opposite. Wouldn't you want to have consistent names? Making two functions that have the same exact effect would make no sense at all. Quote Link to comment https://forums.phpfreaks.com/topic/161845-solved-multiple-function-names/#findComment-853935 Share on other sites More sharing options...
rhodesa Posted June 11, 2009 Share Posted June 11, 2009 Agreed...I would try and keep things consistent. If you change the name of the function for some reason, and want to keep the old name for depreciation purposes, I would have the old function name call the new function name. This way you can also add a piece that either displays a DEPRECIATED message, or sends an email to an admin notifying them that something is using the depreciated function name. Quote Link to comment https://forums.phpfreaks.com/topic/161845-solved-multiple-function-names/#findComment-853940 Share on other sites More sharing options...
roopurt18 Posted June 11, 2009 Share Posted June 11, 2009 What rhodesa said. In all of my programs I use set_error_handler() to define my own error handler that logs errors to a file. When a piece of code becomes deprecated, I perform the following: function DoSomething() { trigger_error( 'DEPRECATED: ' . __FUNCTION__ . ' is deprecated, use DoSomethingNew() instead.' ); DoSomethingNew(); } function DoSomethingNew() { // Replaces DoSomething() // Function body follows... } Then once per day, week, or month I have the error log e-mailed to me and start a new one. Quote Link to comment https://forums.phpfreaks.com/topic/161845-solved-multiple-function-names/#findComment-853960 Share on other sites More sharing options...
acctman Posted June 12, 2009 Author Share Posted June 12, 2009 thanks for all the advice... with the help of find and replace i changed all code to run off of one function. Quote Link to comment https://forums.phpfreaks.com/topic/161845-solved-multiple-function-names/#findComment-854724 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.