A single =
is the assignment operator. What you're doing is setting $value
to "fullname"
. What you want is the equals operator ==
or identical operator ===
so you end up with
if ($value === "fullname")
// Do stuff
For more info on operators in php: http://php.net/manual/en/language.operators.comparison.php
Edit:
To answer your comment
Thank you. Really appreciate the help. Is there any way to avoid the error message from line 3 ($value = $_GET['value'] without the isset? Every time I implement the isset, no matter the value entered, it always returns both fullname and email
You can do something like:
if ((!isset($fullname) && !isset($email)) || !isset($value)) {
die("No name or email was included in the request");
}
$value = $_GET['value'];
$fullname = "John Doe";
$email = "johndoe@email.com";
echo "value: " . $value;
if ($value = "fullname") {
echo "fullname: " . $fullname;
} elseif($value = "email") {
echo "email: " . $email;
} else {
echo "fullname: " . $fullname;
echo "<br>";
echo "email: " . $email;
}