[wp-hackers] related posts 1.3.3 issue cont.

Dougal Campbell dougal at gunters.org
Wed Oct 27 20:36:41 UTC 2004


Mark Jaquith wrote:
> Alexander Malov wrote:
> 
>> I've been trying to add a condition to my plugin to replace entry
>> links to posts w/ no title (this happens when somebody imported from
>> blogger) to display a generic link. I tried the following code:
>>
>> if ($result->post_title = ' ') {
>> $title = 'Generic link title';
>> }
>>
>> But it affects all titles for reasons unknown to me ... yeah, I know.
>> If anyone can point me in the right direction I would be very
>> grateful.
>>
> I once made the same mistake and nearly tore the hair from my scalp.
> 
> remember, "=" sets equality, "==" tests for equality.
> 
> if ($result->post_title == ' ') {
> $title = 'Generic link title';
> }

Which is why the WordPress Coding Style Guidelines suggest that you 
should put constant text on the left side of a condition. Because then, 
if you had

   if (' ' = $result->post_title)

PHP would throw a parsing error, and you'd know that it needed fixing :)

-- 
Ernest MacDougal Campbell III, MCP+I, MCSE <dougal at gunters.org>
http://dougal.gunters.org/             http://spam.gunters.org/
   Web Design & Development:  http://www.mentalcollective.com/
        This message is guaranteed to be 100% eror frea!



More information about the hackers mailing list