PHP - Plus sign with GET query

后端 未结 6 1462
余生分开走
余生分开走 2020-11-27 20:49

I have a PHP script that does basic encryption of a string through the method below:



        
6条回答
  •  自闭症患者
    2020-11-27 21:16

    We ran into the same problem trying to pass a URL to a PHP script with a string variable containing the "+" symbol. We were able to make it work with;

    encodeURIComponent([string])
    

    EG:

    var modelString = "SEACAT+PROFILER";
    modelString = encodeURIComponent(modelString);
    //"SEACAT%2BPROFILER"
    

    The %2B passes the correct value to the PHP GET as @hobodave said, and we get back the right data set.

    Hope this helps someone else who ran into something like this, and needed a slightly different take on the examples above.

提交回复
热议问题