How to use isset() with multiple variables

Categorized as PHP

There is a smart way of using the isset() function in PHP when dealing with several variables.

The old-fashioned way:

if ( isset($variable1) && isset($variable2) && isset($variable3) ) {
    ...
}

The easiest and smart way to use isset() with multiple variables:

if ( isset($variable1, $variable2, $variable3) ) {
    ...
}

Leave a reply

Your email address will not be published. Required fields are marked *