Harsh
Harsh

Reputation: 2096

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++;
}

Upvotes: 4

Views: 16430

Answers (1)

Brett Zamir
Brett Zamir

Reputation: 14365

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

Upvotes: 17

Related Questions