String In String Reverse
July 25th, 2006 by Harald Ponce de LeonPosted in PHP
I just experienced another nasty PHP4 / PHP5 compatibility issue that plagued the logging features of the support site administration tool (which is planned to be introduced in the 3.0 Alpha 4 release).
The implementation uses the strrpos() function to grab the end of a string from a string searched starting point. The opposite function is strpos() that searches from the start of the string instead from the end.
The string to search for, the needle, can be a character or a string for the normal strpos() function in both PHP 4 and PHP 5.
There is however a difference with the strrpos() function where PHP 4 accepts the needle as a character only, and can first be a string from PHP 5 onwards.
This took some time to debug where my local server is running on PHP 5 with the logging features working fine, and the support site running PHP 4 where the issue was first evident.
There is a warning about this on the documentation page which I overlooked during the implementation phase. Such incompatibility warnings should be marked with the infamous <blink> tag so they stand out better
The positive side to this is the valuable user comments on the php documentation pages where numerous functions are provided to workaround the problem.
Workaround functions are obviously not elegant solutions to use, and will look at improving the logic further for the 3.0 Alpha 4 release.
