PHP
PHP Math Functions - pi, abs, sqrt, min, max, rand, round, floor, ceil, pow, is_nan, is_numeric
¶PHP Math Function
PHP has several built in methods to work with Mathematics. Let’s get the list of that -
Method Name | Description | Example | Result |
---|---|---|---|
pi() | Get Pi number value | echo pi(); // 3.1415926535898 |
Return PI value |
abs() | Get the absolute value of a variable or operand | echo abs(-1); // 1 |
Return Positive value of integer |
min(val1, val2) | Get the minimum value of two or multiple variable or multiple operand | echo min(10, 20); // 10 |
Return minimum value |
max(val1, val2) | Get the maximum value of two or multiple variable or multiple operand | echo max(10, 20); // 20 |
Return maximum value |
sqrt(val) | Get the square root of a variable or operand | echo sqrt(64); // 8 |
Return square root value |
rand() or rand(min, max) | Get a random integer | echo rand(5, 10); // 8 |
Return random integer value between those range. |
round(floatvalue) | Get a rounded value | echo round(3.4); // 3 echo round(3.5); // 4 |
Return round value of any float number. |
floor(floatvalue) | Get a lowest integer value | echo floor(3.6); // 3 |
Return lowest value of any float number. |
ceil(floatvalue) | Get a highest integer value | echo ceil(3.1); // 4 |
Return highest value of any float number. |
pow(num, exponent) | Get a power of a number | echo pow(5, 2); // 25 |
Return power value of a number. |
is_nan(num) | Check if the value of is not number. | echo is_nan("test"); // true |
Return true if the num is Not a Number. |
is_numeric(num) | Check if the value of is a number. | echo is_numeric("test"); // false |
Return true if the num is a valid Number. |
Previous
PHP If-else-elseif and Switch-case
PHP If-else-elseif and Switch-case
Next
PHP String Functions - All necessary String functions in PHP to manage strings better.
PHP String Functions - All necessary String functions in PHP to manage strings better.
Advertisements
All Tutorials in this playlist
Popular Tutorials
Categories
-
Artificial Intelligence (AI)
11
-
Bash Scripting
1
-
Bootstrap CSS
0
-
C Programming
14
-
C#
0
-
ChatGPT
1
-
Code Editor
2
-
Computer Engineering
3
-
CSS
28
-
Data Structure and Algorithm
18
-
Design Pattern in PHP
2
-
Design Patterns - Clean Code
1
-
E-Book
1
-
Git Commands
1
-
HTML
19
-
Interview Prepration
2
-
Java Programming
0
-
JavaScript
12
-
Laravel PHP Framework
37
-
Mysql
1
-
Node JS
1
-
Online Business
0
-
PHP
28
-
Programming
8
-
Python
12
-
React Js
19
-
React Native
1
-
Redux
2
-
Rust Programming
15
-
SEO - Search Engine Optimization
1
-
Tailwind CSS
1
-
Typescript
10
-
Uncategorized
0
-
Vue JS
1
-
Windows Operating system
1
-
Woocommerce
1
-
WordPress Development
2
Tags
- Artificial Intelligence (AI)
- Bash Scripting
- Business
- C
- C Programming
- C-sharp programming
- C++
- Code Editor
- Computer Engineering
- CSS
- Data Structure and Algorithm
- Database
- Design pattern
- Express JS
- git
- Git Commands
- github
- HTML
- Java
- JavaScript
- Laravel
- Mathematics
- MongoDB
- Mysql
- Node JS
- PHP
- Programming
- Python
- React Js
- Redux
- Rust Programming Language
- SEO
- TypeScript
- Vue JS
- Windows terminal
- Woocommerce
- WordPress
- WordPress Plugin Development
Advertisements