Re: why does trim() remove NUL?
| From: | John A. Grant | Date: | Fri, 19 Oct 2001 20:43:38 +0000 |
| Subject: | Re: why does trim() remove NUL? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71627@lists.php.net to get a copy of this message | ||
"_lallous" <elias_bachaalany@yahoo.com> wrote in message
news:20011015134600.22033.qmail@pb1.pair.com...
> I guess if strlen() fails it returns 0 and if string has no length then it
> also returns zero.
>
> I don't think PHP's strings are zero terminated.
>
> $str = "abc\xab\x00defgh";
> echo $str;
> outputs: abc½ defgh
>
> and doesn't truncate the string.
Thanks. I guess I should have tried that to see what
happens. Interesting. I guess both C and php use
an array of char. The difference is that there is no length
attribute in C arrays, so you have to mark the end with \0.
php arrays have a length attribute, so \0 terminator is
unnecessary.
--
John A. Grant * I speak only for myself * (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here