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.
<?php
substr_replace('eggs','x',-1,-1); substr_replace('eggs','x',-1,-2); substr_replace('eggs','x',-1,-2); ?>
Same as:
<?php
substr_replace('eggs','x',-1,0); ?>
<?php
substr_replace('huevos','x',-2,-2); substr_replace('huevos','x',-2,-3); substr_replace('huevos','x',-2,-3); ?>
Same as:
<?php
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)
<?php
substr_replace('abcd', 'x', 0, -4); ?>
Same as:
<?php
substr_replace('abcd','x',0,0); ?>
<?php
substr_replace('abcd', 'x', 1, -3); ?>
Same as:
<?php
substr_replace('abcd', 'x', 1, 0); ?>