Hi all,
Can anyone tell me what is the other way of writing this:
$username = (isset($_POST['username'])) ? $_POST['username'] : '';
a comment explaining it would be very helpful.
Thanks.
The other way of writing this is with an if else statement but there's no need to write it another way if it's doing what you require.
The code you posted is a ternary statement, you can read about the ternary operator in the PHP manual look at example 2 Assigning a default value. http://php.net/manual/en/language.operators.comparison.php