Simple sample code for PHP math functions

Source: Internet
Author: User
Tags floor function
  1. A small example of a PHP math function-bbs.it-home.org
  2. Echo ABS (-1);//Take absolute value function
  3. echo "
    ####### #ceil, floor function ######
    ";
  4. echo ceil (1);//Take the smallest integer greater than the parameter
  5. Echo Ceil (-1.1);
  6. echo "
    ";
  7. Echo Floor (1.1);//Take the maximum integer less than the parameter
  8. Echo Floor (-1.1);

  9. echo "
    ####### #max函数 ######
    ";

  10. echo Max (+//) Take 1 and 2 maximum
  11. echo "
    ";
  12. $arr =array (1,2,3,4,5,7,6);
  13. echo Max ($arr);//The maximum value in an integer array

  14. echo "
    ####### #pow函数 ######
    ";

  15. Echo Pow (5,2);//Output 5 2-time value

  16. echo "
    ####### #round函数 ######
    ";

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

  18. echo "
    ####### #rand函数 ######
    ";

  19. for ($i =0; $i <1000; $i + +) {
  20. $temp =rand (0,9), or//Take an integer value from 0 to 9, which can be taken to the upper and lower values
  21. /*
  22. if ($temp ==0)
  23. {
  24. echo "can take the value of the lower limit";
  25. Break
  26. }
  27. */
  28. if ($temp ==9)
  29. {
  30. echo "can fetch the upper limit value";
  31. Break
  32. }
  33. }

  34. ?>

Copy Code
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.