search
HomeBackend DevelopmentPHP ProblemHow to quickly learn PHP operators in one day (detailed introduction)

The previous article introduced you to "Selected flow control statements--break statement and continue statement (with detailed explanation) ". This article continues to introduce to you how to quickly understand PHP in one day (detailed introduction), I believe you will definitely make new discoveries and gains, come on, let’s explore together!

How to quickly learn PHP operators in one day (detailed introduction)

l Logical operator:

Concept:

Perform logical operations on expressions to calculate The result is a Boolean type value (true, false)

Requirements:

The value of the expression participating in the logical operation is a Boolean type value. If not, it will be blocked by PHP Automatically converted into a Boolean value

(1) Logical AND and or &&

When the values ​​of the left and right expressions are both true, the operation result is true, and vice versa. As long as one of them is false, the operation result is false;

The following values ​​will be considered false, and other values ​​will be considered true

①Boolean value false

② 0

③ Floating point type 0.0

④ Blank string and string 0

⑤ Array with no members

⑥ null

(2) Logical OR or or ||

If one of the values ​​of the expressions on the left and right sides is true, the result of the operation is true. Only when the values ​​on both sides are false, the result is false

(3) Logical exclusive OR The value of the expression is negated. It used to be false and now it is true, and vice versa.

l Other operators

(1)Ternary operator? :

Expression 1?Expression 2:Expression 3;If the value of expression 1 is true, then execute expression 2, otherwise execute expression 3

( 2) ` `operator

can put system commands in it for execution (involving cross-platform)

(3)@operator

The shielding expression may cause errors

(4)

(5)

(6)

l Operator precedence

Use Parentheses can treat a certain part of the expression as a whole

1. Using parentheses can enhance the readability of the code2. Some places do not need to add parentheses, but you can also add them. , Increase the readability of statements

Short-circuit problem

Programming language designers believe that as long as there are logical operators (logical AND, logical OR), the result of the operation is true or false, the running process is not important

$a=false;
$b=1;
$a && ++$b;
Echo $b;//短路,上面的++$b被短路了,结果还是1

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to quickly learn PHP operators in one day (detailed introduction). For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
c语言开根号运算符是什么c语言开根号运算符是什么Mar 06, 2023 pm 02:39 PM

在c语言中,没有开根号运算符,开根号使用的是内置函数“sqrt()”,使用语法“sqrt(数值x)”;例如“sqrt(4)”,就是对4进行平方根运算,结果为2。sqrt()是c语言内置的开根号运算函数,其运算结果是函数变量的算术平方根;该函数既不能运算负数值,也不能输出虚数结果。

Java中的%是什么意思Java中的%是什么意思Mar 06, 2023 pm 04:48 PM

在Java中,“%”是取余的意思,是一个二元算术运算符,可进行除法运算并获取余数,语法“操作数1 % 操作数2”。取余运算符“%”的操作数通常是正整数也可以是负数甚至是浮点数,如果负数参与此运算,则结果的正负取决于前面一个数是正数还是负数。

golang 报错:“invalid use of … operator” 如何解决?golang 报错:“invalid use of … operator” 如何解决?Jun 24, 2023 pm 05:54 PM

对于Golang开发者来说,“invaliduseof…operator”是一个常见的报错。这个报错通常会在使用变长参数函数时出现。它在编译时就会被检测出来,并指出哪些部分有问题。这篇文章将介绍如何解决这个报错。一、什么是变长参数函数变长参数函数也被称为可变参数函数,是Golang语言中的一种函数类型。使用变长参数函数可以像如下方式定义多个

php中“==”符号的含义是什么php中“==”符号的含义是什么Mar 14, 2023 pm 07:05 PM

在php中,“==”符号是一个比较运算符,可以比较两个操作数是否相等,语法“操作数1 == 操作数2”。“==”运算符会比较、并测试左边的变量(表达式或常量)是否与右边的变量(表达式或常量)具有相同的值;它只比较变量的值,而不是数据类型。如果两个值相同,则返回true值;如果两个值不相同,则返回false值。

php怎么判断两个数能否整除php怎么判断两个数能否整除Jan 10, 2023 pm 03:12 PM

在php中,可以使用“%”和“==”运算符来判断两个数能否整除;只需要使用“%”运算符将两个数相除获取余数,再使用“==”运算符判断获取的余数是否为0即可,语法“数1 % 数2 == 0”,如果为0则能整除,如果不为0则不能整除。

Python中的魔法方法Python中的魔法方法Apr 13, 2023 am 10:25 AM

python中的魔法方法是一些可以让你对类添加“魔法”的特殊方法,它们经常是两个下划线包围来命名的。Python的魔法方法,也称为dunder(双下划线)方法。大多数的时候,我们将它们用于简单的事情,例如构造函数(init)、字符串表示(str, repr)或算术运算符(add/mul)。其实还有许多你可能没有听说过的但是却很好用的方法,在这篇文章中,我们将整理这些魔法方法!迭代器的大小我们都知道__len__方法,可以用它在容器类上实现len()函数。但是,如果您想获取实现迭代器的类对象的长度

go语言运算符优先级怎么排序go语言运算符优先级怎么排序Dec 21, 2023 pm 05:03 PM

在Go语言中,运算符按照优先级从高到低的顺序进行计算。常见的运算符的优先级顺序:1、括号:()(最高优先级,用于强制改变运算顺序);2、​单目运算符;3、乘性运算符;4、加性运算符;5、移位运算符;6、按位运算符;7、比较运算符;8、逻辑运算符;9、条件运算符(三元运算符);10、赋值运算符等等。

JavaScript的位左移(<<)运算符是什么?JavaScript的位左移(<<)运算符是什么?Sep 13, 2023 pm 12:37 PM

使用按位左移运算符,从右侧移动一个或多个零位。不考虑最左边的位。示例您可以尝试运行以下代码来了解如何使用JavaScript按位左移运算符。<!DOCTYPEhtml><html>&nbsp;&nbsp;<body>&nbsp;&nbsp;&nbsp;<script>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write("B

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.