当前位置:网站首页>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.
边栏推荐
- 宝塔搭建企业招聘网站源码实测
- 一加Ace值得买吗?用实力诠释性能的强大
- 每周推荐短视频:为了填补学习资源的空缺,作者专门写了本书?
- Cyanine5.5 alkyne|Cy5.5 alkyne|1628790-37-3|Cy5.5-ALK
- LeetCode - 102. 二叉树的层序遍历;110. 平衡二叉树;098. 验证二叉搜索树
- “vite”和“vite预览”有什么区别?
- 【Azure 事件中心】使用Azure AD认证方式创建Event Hub Consume Client + 自定义Event Position
- 5v2.1a给5v2a充电行吗
- Unable to start SinkRunner: { policy:org.apache.flume
- 快手通过国际权威信息安全和隐私保护认证,安全能力达到国际领先水平
猜你喜欢
随机推荐
Arduino实验三:继电器实验
2022/08/02------丑数
什么是鉴权?一篇文章带你了解postman的多种方式
域名抢注“卷”到了表情包?ENS逆势上涨的新推力
Trie思想及模板
Dataworks中PyOdps里面pandas.read_sql()支持Odps吗?
VsCode预览Geojson数据
动态接口比例性能测试实践
Postgresql 备份大小情况!
宝塔搭建企业招聘网站源码实测
Map和Set
pydev debugger: warning: trying to add breakpoint to file that does not exist: /tmp/xxx
使用o.execute_sql 查询很很很小的表, 要7/8秒钟, 这个怎么解决
你想知道的 Watch App 开发
Uniswap或将开启“费用开关”,UNI持有者可享受分红
Oracle备份的几种方式
【技术白皮书】第二章:OCR智能文字识别回顾——自然语言文本发展历程
关于vscode安装包下载太慢解决方法
Interpretation of the paper (JKnet) "Representation Learning on Graphs with Jumping Knowledge Networks"
87.(cesium之家)cesium热力图(贴地形)