Home  >  Article  >  Backend Development  >  How to remove numbers after decimal point in php

How to remove numbers after decimal point in php

藏色散人
藏色散人Original
2021-09-19 09:43:162917browse

php method to remove numbers after the decimal point: 1. Create a new php file; 2. Use the header() method to set the encoding format of the page to utf-8; 3. Use the intval function to round to remove Just the number after the decimal point.

How to remove numbers after decimal point in php

#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.

How to remove the numbers after the decimal point in php?

Create a new php file, named test.php, to explain how php does not need numbers after the decimal point.

How to remove numbers after decimal point in php

In the test.php file, use the header() method to set the encoding format of the page to utf-8 to avoid outputting Chinese garbled characters.

How to remove numbers after decimal point in php

In the test.php file, save the number to be processed in the $num variable.

How to remove numbers after decimal point in php

In the test.php file, use the intval() function to round to remove the numbers after the decimal point.

How to remove numbers after decimal point in php

In the test.php file, use echo to output the results.

How to remove numbers after decimal point in php

Open the test.php file in the browser to view the results.

How to remove numbers after decimal point in php

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How to remove numbers after decimal point in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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