For all you rabid PHP developers out there, I'll occasionally be passing along some stuff I found out while working on various projects I am involved with (both inside and outside of work). Some of these revelations may seem trivial to you, but they are virtually epiphanies to me, and hope that somebody might find use of my ramblings.
Today is a short fact regarding the substr() function. Were you aware that as of version 5.2.3, putting a negative value for the position parameter that is longer than the length of the string will result in an empty string, instead of the whole string? I wasn't, and it certainly perplexed me.
Example:
$bar = 'Quo Vadimus is awesome';
$foo = substr( $bar, -54);
In an older version of PHP, $foo would output:
Quo Vadimus is awesome
In 5.2.3 and on, however, it outputs an empty string.
The More You Know...
No comments:
Post a Comment