Well, if I use var_dump("\0") here on my windows7 64 bit machine, it spits
out the following:
string '�' (length=1)
And, if I check out the ascii character code of that blank character here it
returns as 65533
//that's just interpreted using my screenreader's say character code option
on output string
Pretty much just wondering what they meant to do, and would also have
thought it was a form of typo in that they wanted to double check if that
variable, which must have something assigned to it included those
characters/letters, etc.?
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
"Roger Wilco wants to welcome you...to the space janitor's closet..."
----- Original Message -----
From: "Toby Hart Dyke" <toby@xxxxxxxxxxxx>
To: <php-windows@xxxxxxxxxxxxx>
Sent: Tuesday, 19 August, 2014 4:46 PM
Subject: Re: Re: What could the intention be of someone using "\0"
in comparison be?
But what does "\0" mean, and where is it documented? In this context, it
clearly means zero, but not false, so the intention is to check for the
presence of the tested string.
It seems that the backslash means to treat as a literal zero character,
which then gets treated as a "true" zero value, rather than a false. I get
PHP's dynamic typing, but this seems a bit tortuous, and I would always
use your idiom ( !== false) whic is much more the PHP way.
Toby
On 8/19/2014 2:58 PM, Christoph Becker wrote:
Jacob Kruger wrote:
As in, while my first guess would be that they'd meant to use just the
number 0, what would your guesstimate be relating to why someone would
in
fact use the following syntax as part of determining if a certain
phrase/string was included in a variable's value?
//start excerpt...
if (strpos ($text, "<b>") >= "\0")
//end excerpt
???
Well, using "0" or 0 instead of "\0" would result in unintended
behavior. Consider strpos() returning 0, because the $needle is found
at the very beginning of $haystack. See <http://3v4l.org/0uaY6>, where
the second and third results are not desired.
However, I prefer the following way to test that a string is contained
in another string:
if (strpos($haystack, $needle) !== false)
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php