PHP is one of our development languages. It has powerful functions. This article will introduce PHP operators to friends who like PHP. PHP, like other high-level languages, has many PHP operators. Including arithmetic operators, assignment operators, string operators, increment and decrement operators, logical operators, bitwise operators, relational operators, etc.
1. Arithmetic operators
PHP arithmetic operators include + (addition), - (subtraction), * (multiplication), / (division), % ( Take remainder).
PHP assignment operator has += (add the value on the left to the value on the right The value of is assigned to the left), -= (the value on the left minus the value on the right is assigned to the left), *= (the value on the left is multiplied by the value on the right and assigned to the left), /= (the value on the left is divided by The value on the right is assigned to the left), %= (the value on the left is the remainder of the value on the right and assigned to the left), .= (the string on the left is connected to the right and assigned to the left).
3. String operator
The PHP string operator only has the connection symbol ".", which connects two strings.
4. Increment and decrement operators
PHP increment and decrement operators have four forms: $a++; ++$a; $a-- ; --$a.
5. Logical operators
PHP logical operators include! (logical NOT), and (logical AND), && (logical AND), or (logical OR , as long as one of the two expressions is true, the result is true), || (logical OR), xor (exclusive OR, if only one of the two expressions is true, the result is true).
&& and || have higher priority than and and or.
6. Bit operators
Bit operators convert all numbers into binary numbers for calculation.
Bitwise operators include & (bitwise AND), | (bitwise OR), ^ (bitwise XOR), > (bitwise Right shift), ~ (bitwise negation).
7. Relational operators
Relational operators include == (equal), != (not equal), (greater than ), = (greater than or equal to).
8. Other operators
PHP operators also have some operators, such as $ (variable symbol), & (variable pointer, take address), @( Added before the function, no error message is displayed), ?: (ternary operator),, (comma operator), -> (object methods and properties), => (array assignment).
9. Operator priority
PHP operators have priorities. When multiple operators are combined, the one with higher priority is calculated first. The simple understanding is to multiply and divide first and then add and subtract, so I won’t go into details here.

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

在PHP中,可以利用implode()函数的第一个参数来设置没有分隔符,该函数的第一个参数用于规定数组元素之间放置的内容,默认是空字符串,也可将第一个参数设置为空,语法为“implode(数组)”或者“implode("",数组)”。

查找方法:1、用strpos(),语法“strpos("字符串值","查找子串")+1”;2、用stripos(),语法“strpos("字符串值","查找子串")+1”。因为字符串是从0开始计数的,因此两个函数获取的位置需要进行加1处理。

PHP是一种广泛使用的开源服务器端脚本语言,它可以处理Web开发中所有的任务。PHP在网页开发中的应用广泛,尤其是在动态数据处理上表现优异,因此被众多开发者喜爱和使用。在本篇文章中,我们将一步步地讲解PHP基础知识,帮助初学者从入门到精通。一、基本语法PHP是一种解释性语言,其代码类似于HTML、CSS和JavaScript。每个PHP语句都以分号;结束,注

转化方法:1、使用“mb_substr($url,stripos($url,"?")+1)”获取url的参数部分;2、使用“parse_str("参数部分",$arr)”将参数解析到变量中,并传入指定数组中,变量名转为键名,变量值转为键值。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

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.

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
