PHP-Mathematical Functions


ABS(expr)
  
This function returns the absolute (positive) value of expr.

SIGN(expr)
  
This function returns -1, 0, or 1 depending on whether expr is negative, zero, or positive, respectively.

MOD(expr1,expr2),expr1 % expr2
  
This function returns the remainder of dividing expr1 by expr2.

FLOOR(expr)
  
This function rounds down expr. returns the largest integer value that is less than or equal to expr.

CEILING(expr)
  
This function rounds up expr . returns the smallest integer value that is greater than or equal to expr.

ROUND(expr)
  
This function returns expr rounded to the nearest integer. Note that the behaviour when the value is exactly an integer plus 0.5 is system dependant. Thus, you should not rely on any particular outcome when migrating to a new system.

ROUND(expr,num)
  
This function rounds expr to a number with num decimal places, leaving trailing zeroes in place. Use num=2, for example, to format a number as dollars and cents. Note that the same uncertainty about the rounding of 0.5 applies as discussed for ROUND above.

EXP(expr)
  
This function returns eexpr, the base of natural logarithms raised to the power of expr.

LOG(expr)
  
This function returns ln expr, or logarithm of expr.

Remember, a logarithm with an arbitrary base B can be calculated as LOG(expr)/LOG(B).

LOG10(expr)
  
This function returns the base-10 logarithm of expr.

POW(expr1,expr2),POWER(expr1,expr2)
  
This function returns expr1 raised to the power of expr2.

SQRT(expr)
  
This function returns the square root of expr.

PI()
  
This function returns the value of πpi.

COS(expr)
  
This function returns the cosine of expr in radians
SIN(expr)
  
This function returns the sine of expr in radians (e.g. SIN(PI()) = 0).
TAN(expr)
  
This function returns the tangent of expr in radians (e.g. TAN(PI()) = 0).
ACOS(expr)
  
This function returns the arc cosine (cos-1 or inverse cosine) of expr (e.g. ACOS(-1) = 3.141593).
ASIN(expr)
  
This function returns the arc sine (sin-1 or inverse sine) of expr (e.g. ASIN(0) = 3.141593).
ATAN(expr)
  
This function returns the arc tangent (tan-1 or inverse tangent) of expr (e.g. ATAN(0) = 3.141593).
ATAN(y,x),ATAN2(y,x)
  
This function returns the angle (in radians) made at the origin between the positive x axis and the point (x,y) (e.g. ATAN(1,0) = 1.570796).
COT(expr)
  
This function returns the cotangent of expr (e.g. COT(PI()/2) = 0).
RAND(),RAND(expr)
  
This function returns a random, floating point number between 0.0 and 1.0. If expr is specified, a random number will be generated based on that value, which will always be the same.
LEAST(expr1,expr2,...)
  
This function returns the smallest of the values specified.

GREATEST(expr1,expr2,...)
  
This function returns the largest of the values specified.
DEGREES(expr)
  
This function returns the value of expr (in radians) in 
degrees.
RADIANS(expr)
  
This function returns the value of expr (in degrees) in radians.
TRUNCATE(expr,num)
  
This function returns the value of floating point number expr truncated to num decimal places
Related Posts:
  • PHP-Database-Basics-DB-Arrays Adding MySQL to PHP and combining the applications for your dynamic web site is a great start. But, it helps tremendously to structure your database right. We'll give you a solid understanding of both database de… Read More
  • PHP's variable-related functions PHP's variable-related functions are a key part of the language. Skilled programmers rely on them extensively to build robust code that uses type-checking. Functions like var_dump() and print_r() are also invaluable w… Read More
  • PHP Tutorial PHP Functions Php tutorial - imagemagick php.ini Basics PHP Sessions Cookies Versus Sessions PHP Web-Related Variables PHP ERRORS maximum size of a file uploaded Php Image upload php file_get_conte… Read More
  • Advanced Database Job PHP PHP supports the following databases in one form or another: MySQL— www.mysql.com mSQL— www.hughes.com.au MS SQL (Microsoft SQL server; on Win32 systems only) filePro (Read only)— www.fptech.com Informix— (fr… Read More
  • PHP mail function  sendmail cofiguration in php.ini file  If the smtp server you're trying to relay the    email to requires you to authenticate mail() will fail. <?php // ---------------- SEND MAIL FORM -------------… Read More
  • PHP-Associative Array When you are building an ordinary array, the array function requires the data, but doesn't require you to specify the indices. It automatically generates the index of each element by grabbing the next available intege… Read More
  • php mvc tutorial for beginners-Model-View-Controller In most PHP web applications, you won’t have a strict MVC setup. In fact, it’s quite a lot of work to go full-on MVC with PHP. Getting a web project off the ground can be cumbersome and technically demanding, especially … Read More
  • PHP-simple Form Since you'll need a place for the user to enter a search query, let's begin by building a form to handle the user's input. Every form must have these basic components:The submission type defined with the met… Read More
  • php job in kolkata Learn web design & development with sitepoint tutorials, courses and books -  html5, css3, javascript, php, mobile app development, responsive web design.  In-depth tanking class/job analysis - tutorials and … Read More
  • php.ini Basics After you have compiled or installed PHP, you can still change its behavior with the php.ini file. On Linux/UNIX systems, the default location for this file is /usr/local/php/lib or the lib subdirectory of the PHP installati… Read More
  • PHP-Session Security Because a session may contain sensitive information, you need to treat the session as a possible security hole. Session security is necessary to create and implement a session. If someone is listening in or snoop… Read More
  • Database Functions-PHP MySQL PostgreSQL MS SQL (Microsoft) Chances are good that you will have at least one of these databases available to you (very good since MySQL and PostgreSQL are available for free download). There are four… Read More
  • Php for-web developers   PHP MySQL Functions Free Hosting Requiring Cookies Web Application with PHP php -Mail Functions PHP Array Substrings PHP Comparison Operators for If/Else Statements Showing the Browser and I… Read More
  • PHP Sessions The session_start( ) function is used to create a new session. A session is unique to the interaction between a browser and a web database application. If you use your browser to access several sites at once, you'll hav… Read More
  • Abstract data type In programming, a data set defined by the programmer in terms of the information it can contain and the operations that can be performed with it. An abstract data type is more generalized than a data type constr… Read More