Since the supergroups The $_GET and $_REQUEST automatically launched through the decoding function (equivalent to urldecode() ), you just need to return urlencode() data so that it matches the characters passed to the URL String:
file_put_contents('x.txt', urlencode($_GET['x'])); // -->hello+world file_put_contents('y.txt', urlencode($_GET['y'])); // -->%00h%00e%00l%00l%00o
I tested this locally and it works great. However, from your comments, you can also look at your encoding settings. If the result of urlencode($_GET['y']) is %5C0h%5C0e%5C0l%5C0l%5C0o , then it turns out that the null character you pass in ( %00 ) is interpreted as the literal string "\0" (for example, \ character concatenated from 0 ) instead of correctly interpreting \0 as a single null character.
You should take a look at the PHP documentation for string coding and ASCII device control characters .
source share