Hi all,
I would like to ask about two programming techniques, regarding their efficiancy. First,
is there actually any difference between
<?php
function example() {
if (...) { ... $return_value = value1;}
else if (...) { ... $return_value = value2;}
else (...) { ... $return_value = value3;}
return $return_value;
}?>
and this one
<?php
function example() {
if (...) { ... return $value1;}
else if (...) { ... return $value2;}
else { ... return $value3;}
}?>
Secondly,
<?php
$sql = "SELECT ... FROM ... WHERE..."; // or whatever query
$result = mysqli_query($sql) or die(mysqli_error());
?>
isn't it better this one?
<?php
$result = mysqli_query("SELECT ... FROM ... WHERE...") or die(mysqli_error());
?>
I've seen the first ones in both cases used and was wondering if the second ones are improvements or not... Is there any point in trying to make the code as efficient as possible in PHP, or is it a waste of time? I've being used to think like this since I'm coming from a C/C++ background but don't know if it's worth going to the bottom in PHP, does it really make any difference? Sorry if my questions are naive...
dimitris