Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php magic_在使用$POST数组的共享主机上关闭\u gpc_Php - Fatal编程技术网

Php magic_在使用$POST数组的共享主机上关闭\u gpc

Php magic_在使用$POST数组的共享主机上关闭\u gpc,php,Php,在共享服务器上使用magic quote的***很痛苦,我放弃了上传另一个php.ini来覆盖共享主机php.ini,因为随后出现了其他问题,(配置中的PDO但未加载,等等),我尝试了.htaccess,它给出了500个错误 所以我发现这个解决方案非常好,效果也很好 直到我开始将阵列发布到服务器 <select name="gropu[]"> <option value="1">2</option> <option value="2">1<

在共享服务器上使用magic quote的***很痛苦,我放弃了上传另一个php.ini来覆盖共享主机php.ini,因为随后出现了其他问题,(配置中的PDO但未加载,等等),我尝试了.htaccess,它给出了500个错误

所以我发现这个解决方案非常好,效果也很好

直到我开始将阵列发布到服务器

<select name="gropu[]">
<option value="1">2</option>
<option value="2">1</option>
<option value="3">3</option>
</select>

请帮我解决这个问题,在本地主机上开发一些正常的东西时,这真的让我很恼火,一旦上传到服务器,它就完全错了…

我通常在初始化时运行此操作:

// attempt to disable 'magic quotes' at runtime
@ini_set('magic_quotes_runtime', 0);
@ini_set('magic_quotes_sybase', 0);

// strip slashes if that didn't work
if(get_magic_quotes_gpc()){
  function _strip_slashes_ref(&$var){
    $var = stripslashes($var);
  }

  array_walk_recursive($_POST,    '_strip_slashes_ref');
  array_walk_recursive($_GET,     '_strip_slashes_ref');
  array_walk_recursive($_COOKIE,  '_strip_slashes_ref');
  array_walk_recursive($_REQUEST, '_strip_slashes_ref');
}
魔术引号在5.4中被删除,因此您可能只在以下情况下才想这样做:

version_compare(PHP_VERSION, '5.4.0') < 0
version\u compare(PHP\u版本,'5.4.0')<0

真的吗?你可以在运行时杀死它?是的,我想我正在使用的共享主机少于5.4-u-谢谢你的帮助
magic\u quotes\u runtime
可以在运行时禁用,尽管
array\u map
仅将回调应用于第一级。请注意,
parse\u str
函数依赖于magic quotes选项,因此如果使用该函数,则必须根据结果取消对它们的引用。
// attempt to disable 'magic quotes' at runtime
@ini_set('magic_quotes_runtime', 0);
@ini_set('magic_quotes_sybase', 0);

// strip slashes if that didn't work
if(get_magic_quotes_gpc()){
  function _strip_slashes_ref(&$var){
    $var = stripslashes($var);
  }

  array_walk_recursive($_POST,    '_strip_slashes_ref');
  array_walk_recursive($_GET,     '_strip_slashes_ref');
  array_walk_recursive($_COOKIE,  '_strip_slashes_ref');
  array_walk_recursive($_REQUEST, '_strip_slashes_ref');
}
version_compare(PHP_VERSION, '5.4.0') < 0