Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP if multiple variables exist

So i'm having a bit of a problem with having my PHP run a command if multiple variables exist. I made a simple version for people to see what i'm trying to fix easier. Thanks in advance to anyone who can help :)

<?php
if ((isset($finalusername)) && if (isset($finalpassword)) && if (isset($finalemail)))
  echo "This will save.";
?>
like image 315
Spencer May Avatar asked Jan 25 '12 03:01

Spencer May


People also ask

What does ?: Mean in PHP?

The Scope Resolution Operator (also called Paamayim Nekudotayim) or in simpler terms, the double colon, is a token that allows access to static, constant, and overridden properties or methods of a class.

What is $_ GET in PHP?

PHP $_GET is a PHP super global variable which is used to collect form data after submitting an HTML form with method="get". $_GET can also collect data sent in the URL. Assume we have an HTML page that contains a hyperlink with parameters: <html> <body>

How do you check if two variables are empty in PHP?

When checking with the OR operator ( || ) the code will execute if one or none of them is empty. But you echo both variables even if one of them is empty. What I think you want to do is use the AND operator( && ). This way, the code will only execute if none of the variables are empty.

How do you check if a variable has a value in PHP?

The isset() function checks whether a variable is set, which means that it has to be declared and is not NULL. This function returns true if the variable exists and is not NULL, otherwise it returns false.


1 Answers

if (isset($finalusername, $finalpassword, $finalemail))

Also see The Definitive Guide to PHP's isset and empty.

like image 182
deceze Avatar answered Oct 12 '22 19:10

deceze