Summary of mathematical operation skills in PHP introductory tutorial

高洛峰
Release: 2023-03-03 22:30:01
Original
1382 people have browsed it

The examples in this article describe the mathematical operation skills of PHP introductory tutorial. Share it with everyone for your reference, the details are as follows:

Demo1.php

<?php
// $a = &#39;5&#39;;
// $b = 7+$a;
// echo $b;
  $a = &#39;a&#39;;
  $b = 7+$a;
  echo $b;
?>
Copy after login

Demo2.php

<?php
  $a = 10.0;
  //is_int -- 检测变量是否是整数
  if(is_int($a)) {
    echo &#39;通过&#39;;
  }else{
    echo &#39;不通过&#39;;
  }
?>
Copy after login
Copy after login

Demo3.php

<?php
  $a = 10.0;
  //is_int -- 检测变量是否是整数
  if(is_int($a)) {
    echo &#39;通过&#39;;
  }else{
    echo &#39;不通过&#39;;
  }
?>
Copy after login
Copy after login

Demo4.php

<?php
  //rand -- 产生一个随机整数
  //echo rand(0,10);
  //echo mt_rand(0,100);
  //echo getrandmax();//最大数32767
  //echo mt_getrandmax();//最大数2147483647
?>
Copy after login

Demo5.php

<?php
// $i = 123456789.4454;
// $b = number_format($i,2);
// echo $b;  //123,456,789.45
  $i = 12378456.456789;
  $b = number_format($i,2,&#39;#&#39;,&#39;@&#39;);
  echo $b;//12@378@456#46
?>
Copy after login

Demo6.php

<?php
// $a = -6;
// echo abs($a);//绝对值
// $b = 5.66;
// echo floor($b);//舍去法取整
// echo round($b);//四舍五入
  echo min(1,23,456,87,45,7,54);//1 求最小值或数组中最小值
  echo max(1,23,456,87,45,7,54);//456 求最大值或数组中最大值
  echo pi();//3.14159265359
  echo pow(2,6);//64
?>
Copy after login

I hope this article will be helpful to everyone in PHP program design.

For more articles related to the summary of mathematical operation skills in PHP introductory tutorials, please pay attention to the PHP Chinese website!


Related labels:
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