Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #18430

Re: preg_match(): return vualue

From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: preg_match(): return vualue
Date 2020-11-28 10:57 +0100
Message-ID <i2el7jFdnmlU1@mid.individual.net> (permalink)
References <rpt2dq$1e5k$1@gioia.aioe.org>

Show all headers | View raw


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

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web