当前位置:网站首页>"PHP Basics" use of integer data
"PHP Basics" use of integer data
2022-07-27 08:10:00 【Go home at night】
Functional requirements
Output binary respectively 、 octal 、 Decimal and hexadecimal integers .
The sample code
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title> Output results of different base numbers </title>
</head>
<body>
<?php
$n1 = 123; # Decimal number
$n2 = 0; # zero
$n3 = -123; # negative
$n4 = 0123; # Octal number ( Equal to a decimal number 83)
$n5 = 0x1b; # Hexadecimal number ( Equal to a decimal number 27)
$n6 = 0b1010; # Binary number ( Equal to a decimal number 10)
echo ' Decimal number :'.$n1.'<br>';
echo ' zero :'.$n2.'<br>';
echo ' Negative decimal number :'.$n3.'<br>';
echo ' Octal number :'.$n4.'<br>';
echo ' Hexadecimal number :'.$n5.'<br>';
echo ' Binary number :'.$n6.'<br>';
?>
</body>Running results
Knowledge description
Integer data types can only contain integers . Integer numbers can be in decimal 、 Octal and hexadecimal , Optional symbols can be added to the front (- or +).
Binary expression integer since PHP5.4.0 Available from .
If you want to use octal expression , The number must be preceded by 0( zero ); If you want to use hexadecimal expression , Then the number needs to be preceded by 0x; To use binary representation , The number must be called before 0b.
Be careful : If there are non digits in octal (8 and 9), There is a mistake
Be careful : If the given value exceeds int The maximum range that type can represent , Will be treated as float Type treatment , This situation is called integer overflow . Again , If the final result of the expression exceeds int The range of the type , And will return to float type .
边栏推荐
- [flight control development foundation tutorial 4] crazy shell · open source formation UAV - serial port (optical flow data acquisition)
- Enhancement: BTE process introduction
- On data security
- slf4j如何进行logback配置呢?
- The code interface is a little automated
- vCenter7.0管理Esxi7.0主机
- 二零二零年终总结
- 2020 International Machine Translation Competition: Volcano translation won five championships
- Promise details
- 自动化测试的使用场景
猜你喜欢
随机推荐
You may need an additional loader to handle the result of these loaders.
Redison 3.17.5 release, officially recommended redis client
Download and usage of sequel Pro
DEMO:ST05 找文本ID 信息
3D laser slam: Interpretation of logo-loam paper --- Abstract
Lua迭代器
How does slf4j configure logback?
C commissioned use cases
Promise详解
opengauss从库停掉,发现主库无法写入数据
【飞控开发基础教程4】疯壳·开源编队无人机-串口(光流数据获取)
如何在 60 秒内去分析和定位问题?
shell脚本学习day01
vCenter7.0管理Esxi7.0主机
Data extraction 2
Use of NPM
npm的使用
The code interface is a little automated
What is a rebound shell? What's the use of bouncing shells?
2022/7/26 exam summary




![[applet] how to get wechat applet code upload key?](/img/b4/76e2f12269601c0a969a709ff8a397.png)




