PHP Mobile Internet Development Notes (5)--Basic function Library _php Tutorial

Source: Internet
Author: User
I. Mathematical function library

Floor

Rounding (rounding down)

Float Floor (float $value);

 
   "); Echo (Floor (0.40)."
"); Echo (Floor (5)."
"); Echo (Floor (5.1)."
"); Echo (Floor (-5.1)."
"); Echo (Floor (-5.9)."
")?>


Ceil

Rounding (rounding up)

float ceil (float $value);

 
   "); Echo (Ceil (0.40)."
"); Echo (Ceil (5)."
"); Echo (Ceil (5.1)."
"); Echo (Ceil (-5.1)."
"); Echo (Ceil (-5.9)."
")?>

Max

Take maximum value

Mixed Max (mixed $value, mixed $value, ...);

 
   "); Echo (Max ( -3,5)."
"); Echo (Max ( -3,-5)."
"); Echo (Max (7.25,7.30)."
");? >

Min

Take the minimum value

Mixed min (mixed $value, mixed $value, ...);

 
   "); Echo (min ( -3,5)."
"); Echo (min ( -3,-5)."
"); Echo (min (7.25,7.30)."
");? >

Pow

Power operation

Number POW (number $base, number $expr);

 
   "; Echo Pow (6,2)."
"; Echo Pow ( -6,2)."
"; Echo Pow ( -6,-2)."
"; Echo Pow ( -6,5.5)."
";? >

sqrt

Take the square root

float sqrt (float $arg)

 
   "; Echo (sqrt (1))."
"; Echo (sqrt (9))."
"; Echo (sqrt (0.64))."
"; Echo (sqrt (-9))."
";? >

Rand

Generate random numbers

int Mt_rand (int $min, int max);

 
   "; Echo rand (10,100)."
";? >

Mt_rand

produce a better random number

int Mt_rand (int $min, int max);

Similar to the above Rand usage and output, this is 4 times times faster than Rand.

Round

Rounded

Float round (float $val [, int $precision = 0])

The second parameter is optional, which specifies the number of decimal places reserved

Number_format

Formatting numbers with thousands grouping

Float Number_format (float $number, int $decimals =0, string $dec _point= ", ', String $thousands _sep= ', ');

Second, date time function library

Time

Returns the current UNIX timestamp

int time (void);

 
   "; $nextWeek = time () + (7 * 24 * 60 * 60); 7 days; Hours; mins; 60secsecho ' Now:       '. Date (' y-m-d '). "
Echo ' Next Week: '. Date (' y-m-d ', $nextWeek). "
";? >

Date

Format a local time/date

String Date (string format[, int timestamp]);

GetDate

Get Date/Time information

Array getdate ([int timestamp]);

 
   
MD5 Hash

String MD5 (string $str [, bool $raw _output=false]);

Strpos

Returns the position of the first occurrence of a character in another character

int Strpos (String haystack, mixed needle[, int offset]);


http://www.bkjia.com/PHPjc/755796.html www.bkjia.com true http://www.bkjia.com/PHPjc/755796.html techarticle first, the mathematical function library floor rounding (rounding down) float floor (float $value); "); Echo (Floor (0.40)." "); Echo (Floor (5)." "); Echo (Floor (5.1)." "); Echo (Floor (-5.1)." "); EC ...

  • 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.