how to encode single quotes

你离开我真会死。 提交于 2019-12-06 07:49:39

问题


I want to know how i use htmlentities •' for ' in my code ? How to escape single quote

hows apostrophe work in IE

while($row = pg_fetch_array($result))
{
    if($row[3]=="")
    {

        $vmobj_Array[$i]=$row[0]."***".$row[1]."***".$row[2];
    }
    else
    {
        $vmobj_Array[$i]=$row[0].' ( '.$row[3].' )'."***".$row[1]."***".$row[2];

    }
    $i++;
}

回答1:


I think every question should have an answer, so I'm posting here as well. Feel free to accept the answer someone else posted there just now.

htmlentities($str, ENT_QUOTES); or htmlspecialchars($str, ENT_QUOTES); should do the trick where $str should be replaced by the variable or string you want to escape (e.g., $row[0]). If you just want to add it, all you need to do is add it: print "Here's an apostrophe '";



来源:https://stackoverflow.com/questions/6067113/how-to-encode-single-quotes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!