当前位置:网站首页>PHP Basic Notes-NO.2
PHP Basic Notes-NO.2
2022-08-03 18:10:00 【WDm-xmax】
原id:GUIDM
7Months are so busy that I don't have time to update,I didn't get on eitherCSDNI didn't read all the private messages you sent in time,非常sorry大家.
最近在学习PHP,JavaScriptThe advanced version is temporarily suspended.学习完PHPUpdating content on the front end.
PHPThis column is purely a study note record.感谢大家的支持.
目录
Instructions for other types of conversion values
常量
const/constant,是一种在程序运行中,不可改变的量.
1、常量定义形式
- Use define constants:define(‘常量名’,常量值);
define('PI',3.14);- 使用const关键字定义
const PII=3.14;2、常量名的命名规则
- 常量不需要使用‘$’符号.
- 常量的名字组成由字母、数字和下划线组成,不能以数字开头.
- Constants are dominated by uppercase letters.(与变量以示区别)
- 常量命名的规则比变量要松散,可以使用一些特殊字符,该方式只能使用define定义.
Sometimes it is necessary to use another form to access(For constants that will be specially named)需用:constant();
3、说明
- Use variables where the data may change.
- 数据不一定会变的,mostly use variables.
- 数据不允许被修改的,用常量.
4、系统常量
系统帮助用户定义的常量,用户可以直接使用.
常用的几个系统常量:
PHP_VERSION:PHP版本号
PHP_INT_SIZE:整型大小
PHP_INT_MAX:整型能表示的最大值.PHPMedium integers are allowed to have negative numbers.
5、特殊常量(魔术常量)
双下划线+常量名+双下划线结束.
Magic constants change with the environment,但用户改变不了.
__DIR__:当前被执行的脚本所在电脑的绝对路径.
__FILE__:The absolute address of the current file.
__LINE__:当前所属的行数.
__NAMESPACE__:当前所属的命名空间.
__CLASS__:当前所属的类.
__METHOD__:当前所属的方法.数据类型
data type,在PHP中指的是存储的数据本身的类型,而不是变量的类型.
PHP是一种弱类型语言,变量本身没有数据类型.
1、简单(基本)数据类型
- 布尔型
只有true和false.
用于条件判断.
- 整型
integer(负数-0-无限大)
整型不能包含逗号或空格.
整数是没有小数点的.
整数可以是正数或负数.
Integers can be specified in three formats:十进制、十六进制、八进制.
- 浮点型
float,带小数的数字(负数-0-无限大)
- 字符串
data within quotation marks.
可以是单引号或双引号.
Strings without quotes will give an error.
数字、浮点型、布尔型,Using quotes also belongs to strings.
2、复合数据类型
- 对象类型
object,存放对象.
- 数组类型
array,存储多个数据.
3、特殊数据类型
- 资源类型
resource,存放资源数据.
- 空类型
NULL,只有一个值NULL.
类型转换
在很多条件下,The data type to be specified,External data needs to be converted to the target data type.
- 自动转换:用的比较多,效率偏低.
- 强制(手动)转换:转换过程中,用的较多:转布尔类型(值判断)、转数值类型(算数运算).
Instructions for other types of conversion values
- 布尔值true为1,false为0;
- 字符串转数值有自己的规则:
以字母开头的字符串,永远为0;
以数字开头的字符串,取到碰到字符串为止.
强制转换规则:在变量之前增加一个括号,Then write the corresponding type in the variable.
边栏推荐
- 安装porterLB
- 【白话模电2】二极管特性和分类
- Is OnePlus Ace worth buying?Use strength to interpret the power of performance
- 六、用户身份认证
- Uniswap或将开启“费用开关”,UNI持有者可享受分红
- 【Azure 事件中心】使用Azure AD认证方式创建Event Hub Consume Client + 自定义Event Position
- 【汇编语言02】第2章 寄存器——理论知识
- mysql命令
- 目标检测-YOLOv3理论讲解
- JS string to GBK encoding ultra-reduced implementation
猜你喜欢

架构基本概念和架构本质

WPF 实现柱形统计图

理想L9旗舰级的安全性有多强?守护一家人安全出行“底线”

三丁基-巯基膦烷「tBuBrettPhos Pd(allyl)」OTf),1798782-17-8

Map和Set

Higher mathematics - chapter ten infinite series - constant term series

MySQL database account management and optimization

云GPU如何安装和启动VNC远程桌面服务?

Cyanine5.5 alkyne|Cy5.5 alkyne|1628790-37-3|Cy5.5-ALK

微信小程序分享功能
随机推荐
Atomic Wallet已支持TRC20-USDT
CodeTON Round 2 (Div. 1 + Div. 2, Rated, Prizes), problem: (D) Magical Array
云图说丨初识华为云微服务引擎CSE
cell delay和net delay
WebGL管网展示(及TubeGeometry优化)
高等数学---第十章无穷级数---常数项级数
常见荧光染料修饰多种基团及其激发和 发射波长数据一览数据
2021年数据泄露成本报告解读
BigInteger :new BigInteger(tokenJson.getBytes()).toString(16)什么意思
什么是鉴权?一篇文章带你了解postman的多种方式
架构基本概念和架构本质
pydev debugger: warning: trying to add breakpoint to file that does not exist: /tmp/xxx
七夕
数字IC笔迹-MCMM、WNS和TNS
VsCode preview Geojson data
分享 14 个你必须知道的 JS 函数
Redis:哨兵
计网知识点
NLP的Taskflow API
技术干货|如何将 Pulsar 数据快速且无缝接入 Apache Doris