Re: HTTP Content-length...
| From: | Simon Garner | Date: | Tue, 20 Feb 2001 21:24:18 +0000 |
| Subject: | Re: HTTP Content-length... | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-40815@lists.php.net to get a copy of this message | ||
From: "Hrishi" <hrishi@mediaibc.com>
> > $string ="foo=bar&food=apple";
> > $contentlength=$string.size;
> > $uuencodestring=uuencode($string);
>
> uuencode ? are you looking at urlencode ?
>
> use
> $contentlength=strlen($string);
>
> also remember according to the HTTP protocol, you have to show the length
of
> the encoded string, not the original; which in PHP will look like :
>
> <?
> $string ="foo=bar&food=apple";
> $encodedstring=urlencode($string);
> $contentlength=strlen($encodedstring);
>
> ?>
>
> other methods may or may not work if they're not HTTP compliant.
>
> cheers,
> hrishi
>
Note that you should not urlencode() the string after it's already
URL-formatted.
$string ="foo=bar&food=apple";
$encodedstring=urlencode($string);
echo $encodedstring;
// Will output: foo%3Dbar%26food%3Dapple
If "bar" and "apple" were variables, you would rather urlencode() them
individually.
Cheers
Simon Garner