It's worth noting that when start and length are both negative -and- the length is less than or equal to start, the length will have the effect of being set as 0.
substr_replace('eggs','x',-1,-1); substr_replace('eggs','x',-1,-2); substr_replace('eggs','x',-1,-2); ?>
Same as:
substr_replace('eggs','x',-1,0); ?>
substr_replace('huevos','x',-2,-2); substr_replace('huevos','x',-2,-3); substr_replace('huevos','x',-2,-3); ?>
Same as:
substr_replace('huevos','x',-2,0); ?>
Another note, if length is negative and start offsets the same position as length, length (yet again) will have the effect as being set as 0. (Of course, as mentioned in the manual, when length is negative it actually represents the position before it)
substr_replace('abcd', 'x', 0, -4); ?>
Same as:
substr_replace('abcd','x',0,0); ?>
substr_replace('abcd', 'x', 1, -3); ?>
Same as:
substr_replace('abcd', 'x', 1, 0); ?>