Can I do this? (I can't test it at the moment to see for myself)
public function overSimplifiedTernaryTest($condition = false) {
return ($condition) ? 'someString' : 'someOtherString';
}
It works and next time you can use ideone.com to test your code instead of asking question.
Your code : http://ideone.com/2oHkF
You can also refer to this question for additionnal online tool to test your code.
This is working.
Example:
class CClass
{
public function overSimplifiedTernaryTest($condition = false)
{
return ($condition) ? 'someString' : 'someOtherString';
}
}
$x = new CClass();
echo $x->overSimplifiedTernaryTest(false) .
'\r\n' .
$x->overSimplifiedTernaryTest(true);
delete $x;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With