Hi

I have been going through a tutorial i came across online. Please let me know what this would read if it wasn't written in shorthand. Regards

$products = isset($_SESSION['products']) ? $_SESSION['products'] : array();

Recommended Answers

That's an IF statement:

if(isset($_SESSION['products']))
{
    $products = $_SESSION['products']; 
} else {
    $products = array();
}

Or

$products = array();
if(isset($_SESSION['products']))
{
    $products = $_SESSION['products']; 
}
Jump to Post

All 3 Replies

That's an IF statement:

if(isset($_SESSION['products']))
{
    $products = $_SESSION['products']; 
} else {
    $products = array();
}

Or

$products = array();
if(isset($_SESSION['products']))
{
    $products = $_SESSION['products']; 
}
commented: Legend +1

Thank you very much. Even my lecturer didn't know lol

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.