0

Why is screen echoing?

Hey, I’m confused as to why the screen is echoing “true” when $_GET[“a”] is not equal to “alex”. Any help would be appreciated! Here’s the source code: <html> <head> </head> <body> <h2> Welcome to Variables.php! </h2> </br> Set the variables a, b, and c as you like! </br> </br> <form action="" method="GET"> var a <input type="text" name="a"></br> var b <input type="text" name="b"></br> var c <input type="text" name="c"></br> <input type="submit" name="submit" value="Submit"> </br> </br> <?php echo "var a is equal to "; echo $_GET["a"]; echo "</br> var b is equal to "; echo $_GET["b"]; echo "</br> var c is equal to "; echo $_GET["c"]; if($_GET["a"] = "alex"){ echo "</br> true!"; }else{ echo "</br> false!"; }; ?> </form> </body> </html>

24th Sep 2019, 4:24 AM
Alex
1 Resposta
+ 1
The comparison operator has to be == in your if construct.
24th Sep 2019, 4:30 AM
Michael
Michael - avatar