Simple sample code for php math functions

WBOY
Release: 2016-07-25 08:55:55
Original
1094 people have browsed it
  1. Small example of php mathematical function - bbs.it-home.org
  2. < ;body>
  3. echo abs(-1);//Get the absolute value function
  4. echo "
    ########ceil, floor function######echo ceil(1);//Get the smallest integer greater than the parameter
  5. echo ceil(-1.1);
  6. echo "
    ";
  7. echo floor(1.1);//Get the largest integer less than the parameter
  8. echo floor(-1.1);

  9. echo "
    ########max function######
    ";

  10. echo max( 1,2);//Take the maximum value of 1 and 2
  11. echo "
    ";
  12. $arr=array(1,2,3,4,5,7,6);
  13. echo max($arr );//Get the maximum value in the integer array

  14. echo "
    ########pow function######
    ";

  15. echo pow(5,2);//Output the value of 5 raised to the power of 2

  16. echo "
    ########round function##### #
    ";

  17. echo round(1.511);//Rounding function

  18. echo "
    ########rand function######
    ";

  19. for($i=0;$i<1000;$i++){
  20. $temp=rand(0,9);//Take an integer value between 0 and 9, you can take it up to , the value of the lower limit
  21. /*
  22. if($temp==0)
  23. {
  24. echo "The value of the lower limit can be obtained";
  25. break;
  26. }
  27. */
  28. if($temp==9)
  29. {
  30. echo "The value that can get the upper limit";
  31. break;
  32. }
  33. }

  34. ?>

Copy code


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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!