Isset()/Empty(), Arrays and Ternary Operator
<p>When you need to check is there any value in array and if not - set default value for variable, you do something like this</p>

<pre><code>$authToken = isset($response['fbData']['authResponse']['accessToken']) ? $response['fbData']['authResponse']['accessToken'] : null;
</code></pre>

<p>I wonder, is there any way to do it somehow more readable?</p>

<p>There is short version of trinary ternary operator</p>

<pre><code>$authToken = $sourceVar ?: null;
</code></pre>

<p>No need to repeat source here second time, but it doesn't work with arrays, because if I will use <code>$response['fbData']['authResponse']['accessToken']</code> instead of <code>$sourceVar</code> - I will get php warning message.</p>

<p>I can use <code>@</code></p>

<pre><code>$authToken = @$response['fbData']['authResponse']['accessToken'] ?: null;
</code></pre>

<p>I heard that they make "@" really fast in <code>PHP 5.4</code>, but I don't like this any way.</p>

<p>I could use something like this</p>

<pre><code>$a = isset($response['fbData']['authResponse']['accessToken']) ?: null;
</code></pre>

<p>But in this case I will get TRUE as result, result of <code>isset()</code>.</p>

<p>So, maybe somebody knows, how to do it right?</p>

<p><strong>Upd1:</strong> Suggested topic <a href="http://stackoverflow.com/questions/6347694/how-can-i-create-a-new-operator-in-php">How can I create a new operator in PHP?</a> is not answers my question because there user asks "how to change PHP" and create a new operator. I do not need this. There are some answers how to do similar things without PHP modifications but they are do not work for arrays (I can't pass something like this <code>$response['fbData']['authResponse']['accessToken']</code> in function because it will generate warning message).</p>

<p><strong>Upd2: Problem solved</strong>, thanks to NikiC (see comment below).
The idea: Php wont generate warning message if I will pass array element as a link, so it gives us a chance to use something like this:</p>

<pre><code>function myIsset (&amp;$var, $defaultVal = null) {
    return isset($var) ? $var : $defaultVal;
}

$authToken = myIsset($response['fbData']['authResponse']['accessToken']);
</code></pre>
