string ini_set ( string varname, string newvalue)
Sets the value of the given configuration option. Returns the old value on success, FALSE on failure. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending. 说明中讲的很清楚了,ini_set 返回的是 varname 原来的设置
既然你想做ini_set("magic_quotes_sybase","1")操作,也就表示原来的magic_quotes_sybase=0
当然也就只能输出“no”了
Sets the value of the given configuration option. Returns the old value on success, FALSE on failure. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending. 说明中讲的很清楚了,ini_set 返回的是 varname 原来的设置
既然你想做ini_set("magic_quotes_sybase","1")操作,也就表示原来的magic_quotes_sybase=0
当然也就只能输出“no”了
解决方案 »
- kindeditor兼容问题
- PHP流程实现问题
- Zent Cart PHP 开源项目用JAVA来二次开发可以实现吗??
- 如果将数组的索引和值分别处理成字符串????
- 关于职业规划——做asp的 业余学php 做普通网站尚可,打算明年转 今天主管说公司打算转,net 叫我跟.net团队学 郁闷中!大家给点意见
- 大家帮我看看,是不是很错,说说啊?
- 使用strip_tags不能去掉 的问题
- GD出错了?
- 附件问题!
- 传参奇怪问题【PHP Pchart addPoints方法】
- 高分求解:php中写pdf文件,怎样解决汉字乱码问题,还有那个斜写的www.pdflib.com怎样去掉
- 大家都在用什么PHP开发软件
<?
if (ini_set("magic_quotes_sybase","1")===false)
{
echo "yes";
}else
{
echo "no";
}我用下面的测试
<?
ini_set("magic_quotes_sybase","1");
if ($_POST)
{
echo $_POST['test'];
}
?>
<form name="form1" method="post" action="">
<input name="test" type="text" id="test">
<input type="submit" name="Submit" value="提交">
</form>
当输入test'test的时候显示test\'test,这不是表明设置没有成功吗?
当在php.ini里把magic_quotes_sybase设置为on时,显示test''test
?>
ini_set("magic_quotes_sybase","1");
echo ini_get("magic_quotes_sybase"); //out 1
?>
这显然是修改成功了
但你必须注意到一个事实,这个修改是在程序执行时才有的,而提交的数据此时已经被php系统预处理了
你的修改只在程序执行前有效,而在该期间只能使用被php系统预处理的提交数据
那我想使post过来的数据不转换为test\'test而是使其转换为test''test改怎么写,在不修改php.ini的前提下。
sybase_escape_string或相似的函数。
不过可能sybase用的人不多,而用的人又不会不打开magic_quotes_sybase开关,所以这个转义的函数可能不存在
自己:
$str = str_replace("\'","''",$str);
1是int型 不是字符型。magic_quotes_gpc为on时,php在注册变量时会调用addslashes()函数处理[既转义单引号、双引号、反斜线和nullbyte],但php.ini中还有另外一个选项影响着magic_quotes_gpc和addslashes()函数:当php.ini设置magic_quotes_sybase为on时会覆盖magic_quotes_gpc为on的处理,然而magic_quotes_sybase仅仅是转义了nullbyte和把'变成了''