I know that in a language like C# you can use an if like statement (I know these have a name but cannot remember what it is called) kind of like this:
var variable = this ? true : false;
(I understand that won't be correct, but it's been a while since I have done them, please correct if wrong).
My question is thus: can you do the same kind of thing in PHP, if so how?
(The site has been built in WordPress but this is a question about generic PHP variable assignment over wp_* functionality)
I want to be able to declare a variable as such :
$current_user = if (is_user_logged_in()) {
wp_get_current_user();
} else {
null;
}
and I wondered how I would go about making this a single line variable decloration?