bsmither Posted December 20, 2014 Share Posted December 20, 2014 We know that soon, a number of functions will be removed from PHP. There are Deprecation Warnings. I would like to make experiments with functions that have already been removed, and that have suitable substitutes. For example, the ereg() family of functions and the split() function have a suitable substitute in the preg_*() family of functions. Was there a simple, common function that was available in the core PHP build that is now actually removed as of PHP 5.4 (PHP 5.5, perhaps?), where another function can be used to simulate it? I was thinking of the mysql_*() functions, but these functions, although deprecated, are made available by simply including the extension in the PHP.INI file (as I understand it). That is, I have the mysqli extension and not the mysql extension loaded. Thus, the mysql_*() family of functions is not available. So I would experiment to see what would happen if I created a 'wrapper' function named mysql_connect() with mysqli_connect() inside. I am wanting to make this kind of experiment with a core function, like split(), that is already removed. Quote Link to comment https://forums.phpfreaks.com/topic/293206-removed-function/ Share on other sites More sharing options...
requinix Posted December 20, 2014 Share Posted December 20, 2014 Check the changelog. Removed functions where there are others to replace it? I don't know of any. Lately the removals have been for features that were removed, like import_request_variables() or session_register(). Quote Link to comment https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500221 Share on other sites More sharing options...
bsmither Posted December 20, 2014 Author Share Posted December 20, 2014 Sorry, I should have mentioned I've been through the changelogs. I've scanned the Backward incompatible changes for all 5.x versions and have come up empty. Quote Link to comment https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500224 Share on other sites More sharing options...
QuickOldCar Posted December 21, 2014 Share Posted December 21, 2014 Should just update to mysqli, is not that difficult. Code should be updated because is usually good reasons why those functions were abandoned. Quote Link to comment https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500233 Share on other sites More sharing options...
kicken Posted December 21, 2014 Share Posted December 21, 2014 What exactly are you trying to do as an experiment? There are some listed in the change log if you search. I've no idea what you hope to do though, it makes no sense to me. Quote Link to comment https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500234 Share on other sites More sharing options...
bsmither Posted December 21, 2014 Author Share Posted December 21, 2014 The experiment is to create a "bridge" of functions. Said bridge will allow obfuscated scripts to continue functioning for a while longer. Examine the following scenario (and not an invitation to berate the wisdom of maintaining the usage of such scripts): An expensive plugin to an established PHP application fulfills a highly desirable necessity. Certain parts of the scripts are obfuscated or encoded (ionCube/Zend). The publisher has been abducted by aliens. It will be required that the servers be maintained, in part, by upgrading PHP to the most recent versions. Instead of the costly process of "re-inventing the wheel", these experiments will want to show that for the removed functions, the ereg() family of functions for a specific example, which are present in the encoded scripts and are still required, a wrapper function having the same name, but actually executing the suggested replacement function (preg_*() family), will allow the application to continue to use the plugin scripts unabated. I have searched the change log and have not found a function that has been removed for which there is a suggested replacement. "Should just update to mysqli, is not that difficult." I fear you have entirely missed my point. PHP will be using the mysqli extension, but the expensive, encoded/obfuscated scripts will not be converted. Quote Link to comment https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500238 Share on other sites More sharing options...
QuickOldCar Posted December 21, 2014 Share Posted December 21, 2014 I totally get what you are saying, for the people stuck at a server that won't upgrade, bought an expensive script which now has outdated functions. No longer supported and will not be a newer version. I looked into the same thing like a year ago, I was pulling in all the functions included in a script, determine php version and have a list all available functions, for ones no longer there make a substitute function same name that can do a similar task. It seemed like too much work to me covering every possible version and the multitude of functions along with extensions that could or not be supported. Maybe if there was a few less versions and extensions be a bit easier, is like a mangled web the way it is. Quote Link to comment https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500240 Share on other sites More sharing options...
kicken Posted December 21, 2014 Share Posted December 21, 2014 (edited) Instead of the costly process of "re-inventing the wheel", these experiments will want to show that for the removed functions, the ereg() family of functions for a specific example, which are present in the encoded scripts and are still required, a wrapper function having the same name, but actually executing the suggested replacement function (preg_*() family), will allow the application to continue to use the plugin scripts unabated. Note that the recommended replacement is not always a simple "just use this instead" type of replacement. For example, ereg and split used an entirely different regex engine with different conventions compared to preg. You can't just pass in whatever regex was given to ereg into preg_match and call it a day. You'd have to parse the expression and convert it into a valid preg expression. In general PHP has not really removed much to day, rather just deprecated the functions. The few functions that have been removed are ones that probably nobody used anyway, such as the functions to obtain the logo GUIDs As far as I am aware, probably the only ones currently that are gone that an old script might used would be the session_is_registered/session_register/session_unregister functions. In all honesty, if you have to maintain a script that requires an older version of PHP, you just have to run an older version of PHP. Either fix the script, or don't upgrade. Edited December 21, 2014 by kicken Quote Link to comment https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500244 Share on other sites More sharing options...
requinix Posted December 21, 2014 Share Posted December 21, 2014 (edited) Another thing: there's more to it than just the functions. Like INI settings have changed, and functions have different sets of arguments. You can't really do anything to protect yourself from that. Honestly, the best thing is to just stay on an old version of PHP until the code is ready to upgrade. Edited December 21, 2014 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500247 Share on other sites More sharing options...
bsmither Posted December 21, 2014 Author Share Posted December 21, 2014 "is not always a simple 'just use this instead'" Hence the experiments of using a wrapper. "Either fix the script, or don't upgrade." Can't fix the script, must upgrade. Hence the experiments. "Honestly, the best thing..." Thank you for your comments, responses, and replies. But I was looking for an actual answer. And so, since I can't find a function that's already been removed for which there is a suitable substitute (even when some massaging of the passed parameters is expected for the actual function or short algorithm), nor is anyone else able to actually make mention of such a function, I will have to experiment with the mysql functions. Not ideal as I was looking for a core function. Quote Link to comment https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500266 Share on other sites More sharing options...
kicken Posted December 21, 2014 Share Posted December 21, 2014 must upgrade. Why? What is forcing you to upgrade? If this code is so important, there should be no reason why you're forced to do something which would potentially make it non functional. And so, since I can't find a function that's already been removed for which there is a suitable substituteYou've already been given a few. like import_request_variables() or session_register(). would be the session_is_registered/session_register/session_unregister functions. They do not have replacement functions, but they do have compatibility code that can be written (to a point). Quote Link to comment https://forums.phpfreaks.com/topic/293206-removed-function/#findComment-1500284 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.