New to php. Can anyone tell me what this means?
if(!isset($_POST['submit']) || $Email!=$ConfirmEmail || !$info_str || !$valid_email)
It's a bunch of checks to see if certain variables/post fields aren't set, or if the Email and ConfirmEmail variables don't match.
Broken down into pieces:
if( < IF
!isset($_POST['submit']) < NOT (IS SET (POST FIELD 'submit'))
|| < OR
$Email!=$ConfirmEmail < VARIABLE 'Email' IS NOT EQUAL TO VARIABLE 'ConfirmEmail'
|| < OR
!$info_str < NOT (VARIABLE 'info_str' IS A TRUE VALUE)
|| < OR
!$valid_email < NOT (VARIABLE 'valid_email' IS A TRUE VALUE)
)
Note that due to the !
"nots", many of the conditions are actually the opposite of what they would otherwise be (i.e. positive test if $valid_email
is actually a false value - such as being null
).
IF
There is no element named 'submit' in the _POST array
OR
if $Email is not equal to $ConfirmEmail
OR
$info_str is empty
OR
$valid_email is zero
then do something...mostly split an error to the user.
Effectively it does error checking, ensuring the request has come through a form submit, has a valid email that matches the confirm email and has a non empty $info_str variable value.
It is form validator. If form is submitted and email equal predefined email, and other variables are defined.
if ( // if
!isset($_POST['submit']) // 'submit' element in $_POST array is not set
|| // or
$Email != $ConfirmEmail // $Email does not equal $ConfirmEmail
|| // or
!$info_str // $info_str is false
|| // or
!$valid_email // $valid_email is false
)
!
negates a value. 'foo'
would usually be regarded as true
, the negated !'foo'
is false
. ''
(an empty string) is usually regarded as false
, the negated !''
is true
. See PHP type comparison tables and Logical Operators.
I just needed rearrange the constructs to solve my problem.