开发者

Using stripslashes on a database row php

{$row['info']}

How do I use stripslashes() php function on this?

I've tried : stripslashes({$row['info']开发者_如何学运维}), doesnt work and this: {stripslashes($row['info'])}

Neither work.

Do I have to use a $var first??

Thanks


stripslashes returns the modified string, leaving its argument unchanged. You have to assign the result to a variable:

$var = stripslashes($row['info']);

That said, why are you doing this? You almost certainly shouldn't be. There is no reason to strip slashes on data coming from the database, unless you've double-escaped the slashes when the data was inserted.


Your question is somewhat confusing.

stripslashes() takes parameter and converts backslashed symbols to normal ones. more over, it does not affect the parameter. it returns stripped version.

so $result = stripslashes($source) or $row["info"] in your case.


$var = stripslashes($row['info']);

is more correct. Or in string, use it like this

echo "something".stripslashes($row['info'])." some more thingy";  


It almost seems, that you are using heredoc syntax because of your {}. Question, is why? Are you seriously displaying your results like this?:

echo <<<my_results
Info: {$row['info']}
my_results;

Well, since that is cool way to do so then here is your fix:

$row_info = stripslashes($row['info']);
echo <<<my_results
Info: {$row_info}
my_results;

However, I do not recommend that approach. Rather do it like this:

echo 'Info:' . stripslashes($row['info']);

Because {stripslashes($row['info'])} doesn't work indeed and stripslashes({$row['info']}) is an anecdote!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜