php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68491 abount stripcslashes
Submitted: 2014-11-24 11:06 UTC Modified: 2014-11-24 22:15 UTC
From: 328060173 at qq dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.4.35 OS: window 2010
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
40 - 1 = ?
Subscribe to this entry?

 
 [2014-11-24 11:06 UTC] 328060173 at qq dot com
Description:
------------
//Why the php5.4 does not require stripcslashes function, need and in PHP 5.2??

php 5.4
<?php
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Origin: *");
//获取请求参数
$req = $_REQUEST["req"]; 

//去掉反斜杠
//$req = stripcslashes ( $req );
$arr = json_decode ( $req, true );
print_r($arr);
?>

php 5.2

php 5.4
<?php
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Origin: *");
//获取请求参数
$req = $_REQUEST["req"]; 

//去掉反斜杠
//$req = stripcslashes ( $req );
$arr = json_decode ( $req, true );
print_r($arr);
?>



Test script:
---------------
http://localhost:8080?req={"test":"?","loc":"{"province":"hanzhou"}"}

php 5.4
<?php
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Origin: *");
//获取请求参数
$req = $_REQUEST["req"]; 

//去掉反斜杠
//$req = stripcslashes ( $req );
$arr = json_decode ( $req, true );
print_r($arr);
?>

php 5.2

php 5.4
<?php
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Origin: *");
//获取请求参数
$req = $_REQUEST["req"]; 

//去掉反斜杠
//$req = stripcslashes ( $req );
$arr = json_decode ( $req, true );
print_r($arr);
?>

Expected result:
----------------
return array

Actual result:
--------------
nothing return

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-24 22:15 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-11-24 22:15 UTC] requinix@php.net
I can't say definitively since you haven't given much information, but it's probably because your 5.2 setup had magic_quotes enabled (which adds slashes that you have to remove with stripslashes()) and 5.4 does not have magic_quotes at all.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 11:01:27 2024 UTC