title: what does "nullbyte" really do in php?
body: <p>I know the null byte in PHP may result in some security problems, like LFI/RFI. I checked the manual and it says &quot;As null bytes denote the end of a string in C, strings containing them won't be considered entirely but rather only until a null byte occurs&quot;. So I decided to test this by myself, but I encountered some issues.</p>
  <p>I wrote a test code snippet, as follows:</p>
  <pre><code>&lt;?php
      $a=$_GET['a'];
      echo $a;
      include $a.'.jpg';
      //include 'a.txt';
  </code></pre>
  <p>The filename of this script is &quot;index1.php&quot;. I accessed this file through the url <code>http://localhost/Demo/index1.php?a=a.txt%00</code>. When I ran this script, it displays the following:</p>
  <pre><code>a.txt
  ( ! ) Warning: include(): Failed opening 'a.txt' for inclusion (include_path='.;C:\php\pear') in D:\wamp\www\Demo\index1.php on line 4
  </code></pre>
  <p>The &quot;a.txt&quot; displayed corresponds to the &quot;echo $a&quot; in the script, but it couldn't include the &quot;a.txt&quot; file and instead displayed a warning. When I test the script after changing the code to <code>include &quot;a.txt&quot;</code>, the file &quot;a.txt&quot; is included correctly!</p>
  <p>Why does this happen? I tested this on windows + wamp 3.4.</p>