Which one is the best?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

The first or the second?

The first
2
25%
The second
6
75%
 
Total votes: 8

User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

LiLpunkSkateR wrote:mine would be

Code: Select all

<?php 
//8 lines
if (mysql_query($resultSQL)) { return TRUE; } 
else { return FALSE; } 

if (mysql_query($resultSQL)) { return TRUE; } 
else { return FALSE; } 

if (mysql_query($resultSQL)) { return TRUE; } 
else { return FALSE; }
?>
now THAT is confusing for on the fly browsing...heh
User avatar
devork
Forum Contributor
Posts: 213
Joined: Fri Aug 08, 2003 6:44 am
Location: p(h) developer's network

Post by devork »

mine most of the time

Code: Select all

<?php
if ( mysql_query($query) ){
       return true;
}else{
        return false;
}
#and 
$result = mysql_query($query) or die("$query has Error:".mysql_error() ) ;
?>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

I'd probably do:

Code: Select all

return (mysql_query($query)) ? true : false;
or like Weirdan use forced type-casting (bool).

Mac
Post Reply