Weird PHP behavior if I put exclamation point into variable name

前端 未结 2 1860
北海茫月
北海茫月 2021-01-19 12:21

I have weirdest problem with PHP itself, that I\'ve ever seen.

Setup:

PHP 5.33, (tried PHP 5.2.14 as well) under IIS

Problem

2条回答
  •  佛祖请我去吃肉
    2021-01-19 12:44

    It's not Windows, it's not Apache or any other webserver, it is PHP core.

    I had a look at it - starting from 5.3 to 5.6 and the problem still exists in there: You are not allowed to have an "!" (exclamation mark) or "|" (pipe) inside the session key.

    The Suhosin patch will fix it partially. You are then allowed to have an exclamation mark at any position inside your key, but not at first position, so "foo!" is allowed, but not "!foo". A pipe is still forbidden.

    The fix:

    1. Change session.serialize_handler in your php.ini to php_binary or php_serialize
    2. Restart the webserver.

    Have fun!

提交回复
热议问题