In PHP, Some functions are marked as binary safe functions. It means that the functions works correctly even when you pass binary data. Ex: A string containing non-ascii bytes, null bytes etc..

To say more cleanly, A non binary safe function might be based on null terminated strings, When it sees any null character in the strings these functions ignores anything after it.

Look at the example below,
 
$str1="web";
$str2="webx00Development";

echo strcoll($str1,$str2); // gives 0, treats both strings are equal ( Non-binary safe functions )

echo strcmp($str1,str2); // gives less than 0, which means $str1 less than $str2 ( Binary safe function )

In the above example,

 x  indicates hexadecimal notation.
0x00 = NULL
0x20 = SPACE
0x04 = ENT ( End of Transmission )

 


Comments (0)
Leave a Comment

loader Posting your comment...