weixin_33712987 2016-10-24 17:15 采纳率: 0%
浏览 27

PHP剥离空字节

I have an application where I need to be able to let the users put anything into an input field and am having issues with null bytes. I am passing the data via AJAX to PHP 5.5 and can see it's being passed from the AJAX request correctly, but when I immediately var_dump the $_POST on the PHP side, a string that contained '%00' comes through as ''. As an aside, I'm protecting my database from injection by using query bindings. Also, the user base is exclusively internal to my company. So, I'm not really concerned with the security aspect of it. How can I get PHP to let these null bytes through?

  • 写回答

1条回答 默认 最新

  • weixin_33726313 2016-10-24 17:23
    关注

    Echoing a null-byte in PHP would indeed result in an empty-looking string, so this makes perfect sense.

    echo chr(0); // outputs nothing
    
    评论

报告相同问题?