login form if else

Permalink
I'm a little confused on how to use an if else statement
I can use
<?php
  $u = new User();
  if($u->isLoggedIn()) {
    echo 'Hello '.$u->getUserName();
  }
?>

But how would I alter the statement using else . It just seems to error.
eg. if user is logged in "do this" else "do that"

telnz
 
telnz replied on at Permalink Best Answer Reply
telnz
Oh Crap...should have looked in the documentation further. I found the answer there so have posted it here also:

If/Else If/Else

* Control statements based on the if and elseif constructs must have a single space before the opening parenthesis of the conditional, and a single space after the closing parenthesis.
* Within the conditional statements between the parentheses, operators must be separated by spaces for readability. Inner parentheses are encouraged to improve logical grouping of larger conditionals.
* The opening brace is written on the same line as the conditional statement. The closing brace is always written on its own line. Any content within the braces must be indented with one tab.
* Use of the "elseif" construct is permitted but highly discouraged in favor of the "else if" combination.
* Omitting braces for single-line if's or else's is never allowed.