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

Jon Daley plogworld at jon.limedaley.com
Sat Nov 17 09:57:21 EST 2007


 	I always like to check return values.  But, I think you are right 
in that preg_match probably is returning TRUE in this case, and then the 
matches is empty.  Catching the FALSE from preg_match would catch other 
errors.

On Sat, 17 Nov 2007, Mark Wu wrote:
> If you think check the return value of preg_match is better ....
>
> we can change to it ...
>
> Both way are okay for me ...
>
> 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:52 PM
>> To: LifeType Developer List
>> Subject: Re: [pLog-svn] r6050 - plog/trunk/class/dao
>>
>>  	Ok, fair enough.
>>
>> On Sat, 17 Nov 2007, Mark Wu wrote:
>>
>>> 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
>>>
>>> _______________________________________________
>>> pLog-svn mailing list
>>> pLog-svn at devel.lifetype.net
>>> http://limedaley.com/mailman/listinfo/plog-svn
>>>
>>
>> --
>> Jon Daley
>> http://jon.limedaley.com/
>>
>> Sic friatur crustum dulce.
>> -- Latin for All Occasions
>> _______________________________________________
>> 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/

Now we're cooking with gas on the front right-hand burner.


More information about the pLog-svn mailing list