I came across this script at http://www.php.net/manual/en/function.str-split.php#78040
/**
Returns a formatted string based on camel case.
e.g. "CamelCase" -> "Camel Case".
*/
function FormatCamelCase( $string ) {
$output = "";
foreach( str_split( $string ) as $char ) {
strtoupper( $char ) == $char and $output and $output .= " ";
$output .= $char;
}
return $output;
}
The curios Part Is :
strtoupper( $char ) == $char and $output and $output .= " ";
My Question
- A detailed break down of
strtoupper( $char ) == $char and $output and $output .= " ";and why its valid - This would not work for
break,return,echobut it works for any function includingprint - Is this Best Practice
- Do such code have any advantages or disadvantages
It is same as
For the code
A and B,Bwill be executed ifAis evaluated to true.The difference between
&&andandis&&has higher precedence thanand,.=is between them.