Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to encode single quotes

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++;
}
like image 387
Harsh Avatar asked Dec 02 '22 02:12

Harsh


1 Answers

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 '";

like image 112
Brett Zamir Avatar answered Dec 20 '22 10:12

Brett Zamir