- Binary string literals are explicit
- The actual variable's contents depend on the script encoding
<?php // script is encoded in UTF-8
function varc($s) {
for ($i = 0; $i < strlen($s); ++$i)
echo sprintf("%02X ", ord($s[$i]));
echo "<br/>\n";
}
$s1 = b'weed';
$s2 = b"qua\x72k";
$s3 = b<<<EOBS
gold = 金
EOBS;
echo varc($s1), varc($s2), varc($s3), "\n";
?>
Output
77 65 65 64
71 75 61 72 6B
09 67 6F 6C 64 20 3D 20 E9 87 91
71 75 61 72 6B
09 67 6F 6C 64 20 3D 20 E9 87 91