我有一个变量我通过url作为Geometry
字符串传递,其中一部分是以下字符串:
#Class Geometry
#attribute id
class Geometry(object):
def __init__(self,uid=0):
uid = 0
self.uid = uid
uid += 1 #not sure if this is neseccary. said uniqueId needs to start at 0, nothing about progressing
class Point(Geometry):
def __init__(self,x,y):
Geometry.def__init__(self,uid)
self.x = x
self.y = y
def __str__(self):
return self.uid + self.x + self.y
当我在php中使用jSON
函数读取url并解析字符串时,signature=8W2sp\/J+kC6fh8a88jabNPuA8048sShDnXNOo1jSQ=
符号将被空格替换。有没有办法禁用空格替换parse_str()
。
答案 0 :(得分:3)
当parse_str自动将url_decode应用于给定字符串时,加号将解码为空格字符。要保持加号,您可以使用urlencode。
$arr = array();
$x = "8W2sp/J+kC6fh8a88jabNPuA8048sShDnXNOo1jSQ=";
parse_str(urlencode($x),$arr);
var_dump($arr);