Hello, I have a variable that could be a string or it could be null: Then I want to evaluate $pageid: Is that ok to do, considering $pageid might be null? I heard of putting an @ sign in front to ignore warnings if $pageid is null. Is that the best way to do it? Seems sloppy to me.
I do something similar, but I use the ternary: $pageid = isset($_GET['pageid']) ? intval($_GET['pageid']) : NULL; PHP: Its not sloppy, its better then getting an undefined error. You shouldn't need to put @ to supress errors, as it should'nt give you any errors as the variable is SET.
if(isset($_GET['pageid'])) { $pageid = $_GET['pageid']; } else { $pageid =''; } if($pageid !== 'mypage') { die(); }