Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have to be a bit more specific here. What's the return type? It's a binary string, so often what you see is not what it actually contains.</p> <p>It could start with a few null bytes (i.e. value=0, <code>\0</code> char). Since this byte is used to denote string ends in C and other languages, <code>echo</code> and other functions stop when they encounter a null byte (sometimes the manual says a function is 'binary-safe', which means it does not consider a null byte as string end).</p> <p>Also there are a lot of non-printable characters. They usually have some kind of special meaning (for example character 7 is the "bell" command, type this into your shell to try it out <code>php -r 'echo "\7";'</code>).</p> <p>To find out what's in your string, you could "convert" each char to its hexadecimal representation. You can use <a href="http://php.net/manual/en/function.bin2hex.php" rel="nofollow"><code>bin2hex()</code></a> for this, note that it needs two chars to represent one char of the input string.</p> <pre><code>$ php -r 'var_dump(bin2hex(pack("i",6)));' string(8) "06000000" </code></pre> <p>(The output you see above depends on your hardware.) In my case <code>pack('i', 6);</code> returns the integer in <a href="http://en.wikipedia.org/wiki/Little_endian#Little-endian" rel="nofollow">little-endian</a> format, since I've got an Intel processor.</p> <p>You can see that the first char (<code>06</code>) has the decimal value 6. What you then do is usually look up which character this belongs to. In many cases it's okay to use an ASCII table, but note that in case you're using unicode or any other encoding certain characters could have another meaning. According to my ASCII table, it's the <a href="http://en.wikipedia.org/wiki/Acknowledge_character" rel="nofollow"><code>ACK</code> character</a>. It's a non-printable character, it has control function only.</p> <p>What remains to be explained is why this translates to integer 0. Fortunately that's very easy. Read the PHP manual page on <a href="http://ch.php.net/manual/en/language.types.string.php#language.types.string.conversion" rel="nofollow">casting strings to numbers</a>.</p> <blockquote> <p>If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero).</p> </blockquote> <p>Since the <code>\6</code> char is neither a sign nor a digit (the chars 0-9 are decimal <code>\48</code>-<code>\57</code> or <code>\0x30</code>-<code>\0x39</code> hexadecimal) PHP returns zero.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload