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();
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();
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'];
}
Thank you very much. Even my lecturer didn't know lol
This method is called Ternary Operator, check this: http://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary
bye :)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.