I have some lines of code like this;
A.
if ( isset($_GET["logout"]) && $_GET["logout"] == 1){
do_something;
}
I replace with ( to get rid of the warning) ;
B.
if ( isset( filter_input(INPUT_GET,'logout',FILTER_SANITIZE_NUMBER_INT) ) &&
filter_input(INPUT_GET,'logout',FILTER_SANITIZE_NUMBER_INT) == 1){
do_something;
}
but i end up breaking the application with B. The login screen does not even appear. No error in the apache error log as well.
This is the sample url;
http://192.168.0.91/test-app/?logout=1
What is wrong with my B. syntax/code? I guess i am using filter_input wrongly?
Update1:
php version ->php5-5.4.20-34.3.x86_64 netbeans version -> 8.0.1
There is nothing wrong with A. Disable the hint in Netbeans, or ignore it.
No, there is nothing wrong with B.
filter_inputreturnsnullif the key does not exist, andissetwill returnfalseif the condition isnull, so your logic is fine and the usage of the function is too. The only problem might be that your PHP version is too old. filter_input was introduced in 5.2.0.