Re: OT? passing text variables through html forms.
| From: | Teodor Cimpoesu | Date: | Thu, 29 Jun 2000 23:56:39 +0000 |
| Subject: | Re: OT? passing text variables through html forms. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3923@lists.php.net to get a copy of this message | ||
Hi Travis!
On Thu, 29 Jun 2000, Travis Ruthenburg wrote:
>
> <?
> $var = "This is 'a' test";
> <input type='hidden' name='name' value='$var'>
> ?>
try
<input type='hidden' name='name'
value='<?=rawurlencode($var)?>'>
or
<? echo "<input type='hidden' name='name' value='" .
rawurlencode($var)."'>"; ?>
so on
AFAIK ' and " are not allowed in urls, so they will be translated and I expect
PHP to decode it as any url-encoded content, or you may call rawurldecode() on
the other end.
If you just want to get rid of slashes use addslashes() instead, or you can
selectively escape a set of characters with addcslashes().
-- teodor