dimanche 26 mai 2019

Two empty statement in if in PHP

When I try:

if(empty($_SESSION['student'])){
    echo "HELLO";
    exit();
}

It results HELLO. (As Expected)

But when I try:

if(empty($_SESSION['student']) || empty($_SESSION['teacher'])){
    echo "HELLO";
    exit();
}

This time $_SESSION['teacher'] is already set to 2.

It results HELLO. (NOT As Expected)

It should not display HELLO

Aucun commentaire:

Enregistrer un commentaire