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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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 Dec 26 10:01:29 2024 UTC