Problem in str_replace(" "," "," "); in PHP

im creating a forum for my website. just like any forum, it has some formatting tools like BOLD, ITALICS, UNDERLINE, CODE…and i disabled any HTML tags using str_replace("<","<","$txt") and str_replace(">",">","$txt") and i used to create my own tags…for example for bold, for underline and so on using str_replace("**","<b>","$txt")… my problem is when it comes to

..we all know that any codes or statements in any languages use double quotation (" ")... for example: &lt;?php echo "hello";?&gt;. i can't print the double quote when i used str_replace(""","&quot;","$txt") i got an error and when i used str_replace("\"","&quot;","$txt") and it prints (\") not exactly (") even in single quote it doesnt work. i hope you'll help me get rid of this problem. thanks!