Jump to content

Recommended Posts

How would you test if only one of something is empty but not both? This doesn't seem to be working.

 

<?php
$dollars = $_POST['dollars'];
$cents = $_POST['cents'];
$errors .= (empty($dollars) || empty($cents))
? "<br /><span class=\"error\">Check the price.</span>"
: FALSE;
?>

Link to comment
https://forums.phpfreaks.com/topic/142663-solved-either-or-but-not-both/
Share on other sites

Is XOR the same as ^?

 

Did you read the link:

 

Explanation:

 

An exclusive OR only evaluates to TRUE when exactly one operand is TRUE.

 

To extend your explanation, yes XOR is the same as ^.... but ^ is on the bitwise level, whereas XOR is a normal logical operator for any non-bitwise comparisons.

 

Bitwise:

echo "hallo" ^ "hello"; // Outputs the ascii values #0 #4 #0 #0 #0
// 'a' ^ 'e' = #4

 

Comparison, normal use:

if(!$var XOR !$var2) {
// if one is false and other is not false, but not both

Did you read the link:

 

Yes I did. Then went and did some more research on my own and came back with another question.

 

My apologies, I thought by '^' you were pointing towards Haku's post.  KingPhilip has posted a good explanation.    ;D

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.