Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #18428 > unrolled thread
| Started by | alex <1j9448a02@lnx159sneakemail.com.invalid> |
|---|---|
| First post | 2020-11-28 09:40 +0100 |
| Last post | 2020-11-28 15:09 +0100 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.lang.php
preg_match(): return vualue alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-11-28 09:40 +0100
Re: preg_match(): return vualue Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) - 2020-11-28 08:46 +0000
Re: preg_match(): return vualue alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-11-28 15:09 +0100
Re: preg_match(): return vualue Allodoxaphobia <trepidation@example.net> - 2020-11-28 18:12 +0000
Re: preg_match(): return vualue "J.O. Aho" <user@example.net> - 2020-11-28 10:57 +0100
Re: preg_match(): return vualue alex <1j9448a02@lnx159sneakemail.com.invalid> - 2020-11-28 15:09 +0100
| From | alex <1j9448a02@lnx159sneakemail.com.invalid> |
|---|---|
| Date | 2020-11-28 09:40 +0100 |
| Subject | preg_match(): return vualue |
| Message-ID | <rpt2dq$1e5k$1@gioia.aioe.org> |
From https://www.php.net/manual/en/function.preg-match.php Warning This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function. That is?
[toc] | [next] | [standalone]
| From | Stefan+Usenet@Froehlich.Priv.at (Stefan Froehlich) |
|---|---|
| Date | 2020-11-28 08:46 +0000 |
| Message-ID | <bt5fc20df1i6ef4n3e8%sfroehli@Froehlich.Priv.at> |
| In reply to | #18428 |
On Sat, 28 Nov 2020 09:40:27 alex wrote: > From https://www.php.net/manual/en/function.preg-match.php > Warning This function may return Boolean FALSE, but may also return a > non-Boolean value which evaluates to FALSE. Please read the section on > Booleans for more information. Use the === operator for testing the > return value of this function. > > That is? Immediately above the quoted paragraph: #v+ preg_match() returns 1 if the pattern matches given subject, 0 if it does not, or FALSE if an error occurred #v- A test for (preg_match(...) == 0) will succeed if the match fails OR if an error occurs. Bye, Stefan -- http://kontaktinser.at/ - die kostenlose Kontaktboerse fuer Oesterreich Offizieller Erstbesucher(TM) von mmeike Stefan - der ungewöhnlichste Quatsch seit Konrad Zuse. (Sloganizer)
[toc] | [prev] | [next] | [standalone]
| From | alex <1j9448a02@lnx159sneakemail.com.invalid> |
|---|---|
| Date | 2020-11-28 15:09 +0100 |
| Message-ID | <rptlmg$1vuq$1@gioia.aioe.org> |
| In reply to | #18429 |
Il 28/11/20 09:46, Stefan Froehlich ha scritto: > Immediately above the quoted paragraph: > > #v+ > preg_match() returns 1 if the pattern matches given subject, 0 if it > does not, or FALSE if an error occurred > #v- > > A test for (preg_match(...) == 0) will succeed if the match fails OR > if an error occurs. However, the documentation is not easy to understand.
[toc] | [prev] | [next] | [standalone]
| From | Allodoxaphobia <trepidation@example.net> |
|---|---|
| Date | 2020-11-28 18:12 +0000 |
| Message-ID | <slrnrs54or.1mca.trepidation@vps.jonz.net> |
| In reply to | #18431 |
On Sat, 28 Nov 2020 15:09:12 +0100, alex wrote: > Il 28/11/20 09:46, Stefan Froehlich ha scritto: >> Immediately above the quoted paragraph: >> >> #v+ >> preg_match() returns 1 if the pattern matches given subject, 0 if it >> does not, or FALSE if an error occurred >> #v- >> >> A test for (preg_match(...) == 0) will succeed if the match fails OR >> if an error occurs. > > However, the documentation is not easy to understand. heh... Documentation rarely is. :-)
[toc] | [prev] | [next] | [standalone]
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Date | 2020-11-28 10:57 +0100 |
| Message-ID | <i2el7jFdnmlU1@mid.individual.net> |
| In reply to | #18428 |
On 28/11/2020 09.40, alex wrote: > From https://www.php.net/manual/en/function.preg-match.php > Warning This function may return Boolean FALSE, but may also return a > non-Boolean value which evaluates to FALSE. Please read the section on > Booleans for more information. Use the === operator for testing the > return value of this function. > > That is? Put is simply you can get a result that is 0 (no result) or false (error), these two values are equal if you make a simple comparison of the values var_dump(0 == false); // => bool(true) If you need to distinguish between error and no result you need to see if the values are identical var_dump(0 === false); // => bool(false) In theory the error result could happen when you have a string that should match what you are looking for, but also include data that causes the regex to fail. See https://www.php.net/manual/en/language.operators.comparison.php for more information on comparison operators. -- //Aho
[toc] | [prev] | [next] | [standalone]
| From | alex <1j9448a02@lnx159sneakemail.com.invalid> |
|---|---|
| Date | 2020-11-28 15:09 +0100 |
| Message-ID | <rptlmg$1t7k$1@gioia.aioe.org> |
| In reply to | #18430 |
Il 28/11/20 10:57, J.O. Aho ha scritto: > > Put is simply you can get a result that is 0 (no result) or false > (error), these two values are equal if you make a simple comparison of > the values > > var_dump(0 == false); // => bool(true) > > If you need to distinguish between error and no result you need to see > if the values are identical > > var_dump(0 === false); // => bool(false) > > > In theory the error result could happen when you have a string that > should match what you are looking for, but also include data that causes > the regex to fail. > > See https://www.php.net/manual/en/language.operators.comparison.php for > more information on comparison operators. thanks
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web