I have a PHP script that goes like:-
<?php session_start() ?>
<body>
<?php
try{
$userId=$_GET['userId'];
}
catch(Exception $e){
$userId=$_SESSION['userId2'];
}?>
with $userId=$_GET['userId'];
this being my line number 23.
I'm loading the script using http://localhost/checkIdAbout.php?all=ALL
.
Now clearly my URL doesn't have the value for $userId
, so it'll give an error and that's understandable to me. What I don't understand is that why isn't the try-catch block coming into play? I already stored the value for $_SESSION['userId2']
. So shouldn't during execution the code jump from try to catch and give me the required value for $userId
?
I get the error: Notice: Undefined index: userId in /var/www/html/checkIdAbout.php on line 23
and I just can't get what's wrong. Please help. Thanks!