Why var_dump does not show null bytes?
<p>I had 2 cases where null bytes <code>\0</code> are being appended to my data.</p>

<p>1.Casting object to an array</p>

<pre><code>class myClass {
    private $var;
    function __construct() {}   
}
$myObject = (array) new myClass();
var_dump(array_map("addslashes", array_keys($myObject)));
</code></pre>

<p>Outputs: </p>

<pre><code>array(1) { [0]=&gt; string(14) "\0myClass\0var" } 
</code></pre>

<p>2.When decrypting encrypted data:</p>

<pre><code>function encrypt_data($data) {
    return base64_encode(mcrypt_encrypt(MCRYPT_BLOWFISH , SALT , $data , MCRYPT_MODE_ECB));
}

function decrypt_data($data) {
    $data = base64_decode($data);
    return mcrypt_decrypt(MCRYPT_BLOWFISH , SALT , $data , MCRYPT_MODE_ECB);
}

$data = '12345678901234567 aasdasd';
$edata = encrypt_data($data);
var_dump(addslashes(decrypt_data($edata)));
</code></pre>

<p>Outputs:</p>

<pre><code>string(39) "12345678901234567 aasdasd\0\0\0\0\0\0\0" 
</code></pre>

<p>But I would never notice <code>\0</code>s if not <code>addslashes</code> function. Why just <code>var_dump()</code> does not show those ? <code>var_dump("Hello\0 World");</code> for example outputs 'Hello World'. In my opinion bad representation of data. And as far as I know <code>\0</code> byte is end of char array (string in PHP) in C and PHP is implemented in C.</p>