Re: Converting ampersand in QuickForm

From: Date: Sun, 06 Mar 2005 18:48:46 +0000
Subject: Re: Converting ampersand in QuickForm
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17887@lists.php.net to get a copy of this message
On Sun, 6 Mar 2005 00:30:57 -0800 (PST), fluidliqatyahoodotcom <fluidliq@yahoo.com> wrote: > So i have something like this... > > require_once "HTML/QuickForm.php"; > $form = new HTML_QuickForm("form"); > $form->addElement("text", "txtName", "Enter: ", > array("value" => "&"); > $form->display(); > > Now yes, the value of the text element is an ampersand "&" in there. But the HTML > is converted to its entities &amp; > Is there a way to have its HTML of the ampersand to be in its own character, "&", > rather than "&amp;"? > I need this for a purpose. > How many times do you need to hear this? This is done *for a purpose*. QF assumes that any strings you give it are the actual strings you want displayed and then converts the entities *as it should*. A single ampersand is technically incorrect in an HTML document. I realize that your text already had entities in it (&#12345;) but this should not be. You should be making it so that your DB does not have these entities. It should have the raw text. How are these entires getting into the DB? If it's a script you wrote, what charset is set on that page? Have you tried changing it? How about using chr to convert these? I have not tested this, but: $str = preg_replace('/&#(\d+);/e', 'chr(\1)', $str); -- Justin Patrin

« previous php.pear.general (#17887) next »