How to tell whether a variable is null or undefined in php
<p>Is there a <strong>single</strong> function that can be created to tell whether a variable is NULL or undefined in PHP?  I will pass the variable to the function (by reference if needed) but I won't know the name of the variable until runtime.</p>

<p><code>isset()</code> and <code>is_null()</code> do not distinguish between NULL and undefined.<br>
<code>array_key_exists</code> requires you to know the name of the variable as you're writing your code.<br>
And I haven't found a way to determine the name of a variable without defining it.</p>

<h3>Edit</h3>

<p>I've also realized that passing a variable by reference automatically defines it.</p>

<h3>Elaboration</h3>

<p>Through the collection of these answers and comments I've determined that the short answer to my question is "No". Thank you for all the input.</p>

<p>Here are some details on why I needed this:</p>

<p>I've created a PHP function called <code>LoadQuery()</code> that pulls a particular SQL query from an array of queries and then prepares it for submission to MySQL. Most-importantly I scan the query for variables (like <code>$UserID</code>) that I then replace with their values from the current scope.  In creating this function I needed a way to determine if a variable had been declared, and was NULL, empty, or had a value.  This is why I may not know the name of the given variable until runtime.</p>
