I'm using PHP 7.2.12
I come across following statement from the Type Casting section of PHP Manual :
(binary) casting and b prefix forward support was added in PHP 5.2.1. Note that the (binary) cast is essential the same as (string), but it should not be relied upon.
I didn't understand the above text thoroughly. Someone please explain to me with good explanation.
I studied the following code examples given in PHP Manual on the same page :
<?php
$binary = (binary) $string;
var_dump($binary);
$binary = b"binary string";
var_dump($binary);
?>
Output :
Notice: Undefined variable: string in ..... on line 2
string(0) ""
string(13) "binary string"
If you look at the output above I got the same strings even after the casting to binary. So, what conversion job does binary casting actually do?
Why the binary casting should not be relied upon?
Also, explain to me on what types the binary casting can be done? I mean it's legal.
Nowhere in the PHP manual, there is any explanation or justification in this regard.
Someone please help me out on this by guiding me in a right direction.