How to represent integers in php

(*-*)浩
Release: 2023-02-23 18:58:01
Original
4741 people have browsed it

How to represent integers in php

PHP Integers

Integers are numbers without decimals.

Integer rules:

The integer must have at least one digit (0-9)

The integer cannot contain commas or spaces

Integers cannot have decimal points

Integers can be positive or negative (recommended learning:PHP programming from entry to proficiency)

Integers can be specified in three formats: decimal , hexadecimal (prefix is ​​0x) or octal (prefix is ​​0)

In the following example, we will test different numbers. PHP var_dump() will return the data type and value of the variable:

Example

<!DOCTYPE html>
<html>
<body>

<?php 
$x = 5985;
var_dump($x);
echo "<br>"; 
$x = -345; // 负数 
var_dump($x);
echo "<br>"; 
$x = 0x8C; // 十六进制数
var_dump($x);
echo "<br>";
$x = 047; // 八进制数
var_dump($x);
?>

</body>
</html>
Copy after login

The above is the detailed content of How to represent integers in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template