What I saw in the handbook was
&& $x && $y returns True if both $x and $y are true. | or $x | | $y returns True if at least one of the $x and $y is true.
But why do I often optimistic that many PHP files, including well-known open source programs are all used in reverse??
For example, the conditional judgment code that deletes a message is
Is the administrator && is the publisher of this format? From the manual, this means that the condition of deleting information is both an administrator and a publisher
I don't know what's wrong with the manual.
Reply to discussion (solution)
How do you know you're not out of context?
There is nothing wrong with the usage manual of the logical operators.
As for your example, are you sure that's what you mean?
You want to give an example of where you see the sticky code let's see
You want to give an example of where you see the sticky code let's see
such as the well-known open source forum Discuz a file
if (!defined (' in_discuz ') | |!defined (' IN_ADMINCP ')) {exit (' Access Denied ');}
It is clear that the discuz must be inside the admin page to run it.
If you don't believe it, you can look inside the discuz and see the relevant PHP file.
PHP does not have the function of a custom operator.
There should be no counter-use of ~
And I'm going to tell you if all 2 forms are filled in.
if (Empty ($_post[' a ')) | | empty ($_post[' B ')) {
The ability to be 2 forms is integral and cannot be published
In the PHP manual
if (Empty ($_post[' a ']) && empty ($_post[' B ')) {
Just fill out 1 items and you can publish it.
Already tested!
I'm sorry, there's a parenthesis on it, and you know what that means.
And I'm going to tell you if all 2 forms are filled in.
if (Empty ($_post[' a ')) | | empty ($_post[' B ')) {
The ability to be 2 forms is integral and cannot be published
In the PHP manual
if (Empty ($_post[' a ']) && empty ($_post[' B ')) {
Just fill out 1 items and you can publish it.
Already tested!
None of the code below is written, how do we know if it's the opposite?
Besides, how can you be sure the original author is not thinking like that?
if (Empty ($_post[' a ']) | | empty ($_post[' B '))
As long as there is an empty (including two empty) expression in $_post[' a ' and $_post[' B ']
if (Empty ($_post[' a ']) && empty ($_post[' B '))
The expression is $_post[' a '] and $_post[' B '] two are empty, expressions are established
Obviously, the two are different, although there are two empty representations.
You have to choose an expression that meets your needs according to your business requirements.
And I'm going to tell you if all 2 forms are filled in.
if (Empty ($_post[' a ')) | | empty ($_post[' B ')) {
The ability to be 2 forms is integral and cannot be published
In the PHP manual
if (Empty ($_post[' a ']) && empty ($_post[' B ')) {
Just fill out 1 items and you can publish it.
Already tested!
None of the code below is written, how do we know if it's the opposite?
Besides, how can you be sure the original author is not thinking like that?
I really mean it.
if (Empty ($_post[' a '))) | | empty ($_post[' B ')) { echo "Sorry form is not complete";} Else{ echo "published successfully";}
This type of code in Discuz is considered a form and B form must be filled in to publish
and
if (Empty ($_post[' a '))) && empty ($_post[' B ')) { echo "Sorry form is not complete";} Else{ echo "published successfully";}
It is considered that at least 1 of them can be released.
I also feel strange so the discussion ....
Your own logical question: do you think c=a&&b; Equal to!a or!b =c?
if (!defined (' in_discuz ') | | |!defined (' IN_ADMINCP ')) {
Exit (' Access Denied ');
}
As long as one of them is not satisfied to exit, the scope of judgment to be wider, such as the table is the Quartet, the table is the square table,
Or can be seen as: not the Quartet or the table does not meet the Quartet table. The individual thinks or is used to judge more efficiently.
This indicates that a is empty or B is empty and the form is not filled in completely
if (Empty ($_post[' a '))) | | empty ($_post[' B ')) {
echo "Sorry form is not complete";
}else{
echo "published successfully";
}
This indicates that A and B are both empty to show the form not complete
if (Empty ($_post[' a '))) && empty ($_post[' B ')) {
echo "Sorry form is not complete";
}else{
echo "published successfully";
}
Logically two is different, do not understand why the landlord feel that there is a problem, these are on demand to do it.