[pLog-svn] r6050 - plog/trunk/class/dao

Mark Wu markplace at gmail.com
Sat Nov 17 09:48:56 EST 2007


In php's manual

http://tw2.php.net/manual/tw/function.preg-match.php

The example is come from here. 

> -----Original Message-----
> From: plog-svn-bounces at devel.lifetype.net 
> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of Jon Daley
> Sent: Saturday, November 17, 2007 10:32 PM
> To: LifeType Developer List
> Subject: Re: [pLog-svn] r6050 - plog/trunk/class/dao
> 
>  	Can you show me in the documentation where it says you 
> should ever check the values of $matches if preg_match returns false?
> 
> On Sat, 17 Nov 2007, Mark Wu wrote:
> 
> > If there is nothing match to the pattern, it will return 
> empty array 
> > to the $res array.
> >
> > See this example:
> >
> > <?php
> > $subject = "abcdef";
> > $pattern = '/^def/';
> > preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3); 
> > print_r($matches); ?>
> >
> > The $match will be
> >
> > Array
> > (
> > )
> >
> > Mark
> >
> >> -----Original Message-----
> >> From: plog-svn-bounces at devel.lifetype.net
> >> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of Jon Daley
> >> Sent: Saturday, November 17, 2007 10:03 PM
> >> To: LifeType Developer List
> >> Subject: Re: [pLog-svn] r6050 - plog/trunk/class/dao
> >>
> >>  	What does it mean for $res to be empty (ie. when does 
> that happen)?  
> >> I don't see any references to it being empty in the php 
> >> documentation.  It does seem like we should be checking the return 
> >> value of preg_match though.
> >>
> >> On Sat, 17 Nov 2007, mark at devel.lifetype.net wrote:
> >>
> >>> Author: mark
> >>> Date: 2007-11-17 02:33:02 -0500 (Sat, 17 Nov 2007) New
> >> Revision: 6050
> >>>
> >>> Modified:
> >>>   plog/trunk/class/dao/trackbackclient.class.php
> >>> Log:
> >>> Fixed a bug in trackback client. Weird, why there is no
> >> people complain about this bug when thet use the 
> trackbackUrls fields.
> >>>
> >>> Modified: plog/trunk/class/dao/trackbackclient.class.php
> >>> 
> ===================================================================
> >>> --- plog/trunk/class/dao/trackbackclient.class.php
> >> 2007-11-17 06:54:19 UTC (rev 6049)
> >>> +++ plog/trunk/class/dao/trackbackclient.class.php
> >> 2007-11-17 07:33:02 UTC (rev 6050)
> >>> @@ -122,7 +122,8 @@
> >>>         		return false;
> >>>
> >>>         	preg_match( "/.*<error>(.*)<\/error>.*/",
> >> $s->results, $res );
> >>> -        	if( $res[1] == 1 )
> >>> +
> >>> +        	if( empty($res) || $res[1] == 1 )
> >>>         		return false;
> >>>         	else
> >>>         		return true;
> >>>
> >>> _______________________________________________
> >>> pLog-svn mailing list
> >>> pLog-svn at devel.lifetype.net
> >>> http://limedaley.com/mailman/listinfo/plog-svn
> >>>
> >>
> >> --
> >> Jon Daley
> >> http://jon.limedaley.com/
> >>
> >> Sometimes being smart is a handicap.
> >> Smart people are often too smart to take advice from others.
> >> -- Al Ries
> >> _______________________________________________
> >> pLog-svn mailing list
> >> pLog-svn at devel.lifetype.net
> >> http://limedaley.com/mailman/listinfo/plog-svn
> >
> > _______________________________________________
> > pLog-svn mailing list
> > pLog-svn at devel.lifetype.net
> > http://limedaley.com/mailman/listinfo/plog-svn
> >
> 
> --
> Jon Daley
> http://jon.limedaley.com/
> 
> There is no "I" in Team, but it does contain a silent "scapegoat"
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn



More information about the pLog-svn mailing list