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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: 328060173 at qq dot com
New email:
PHP Version: OS:

 

 [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-2019 The PHP Group
All rights reserved.
Last updated: Mon Dec 09 15:01:24 2019 UTC