I recently migrated a site from PHP4 to PHP5 and though I went through and updated all the code to be PHP5 compatible… I thought… I missed one minute detail buried in the documentation of PHP 5.2.2 (this change was not in PHP 5.0):
start parameter indicates the position of a negative truncation or beyond, false is returned. Other versions get the string from start.
What does this mean? In my case I was truncating some line break characters from the end of a string, which had been working fine for at least 5 years on PHP4, like so:
$cur_row = substr($cur_row,'',-2); //This works up to and including PHP 5.2.1
However as of 5.2.2 it started returning FALSE instead! Talk about difficult to track down…
Anyhow, the updated syntax is as follows:
$cur_row = substr($cur_row,0,-2); //This works on all versions