Turn Your Vehicle Into a Smart Earning Asset

While you’re not driving your car or bike, it can still be working for you. MOTOSHARE helps you earn passive income by connecting your vehicle with trusted renters in your city.

🚗 You set the rental price
🔐 Secure bookings with verified renters
📍 Track your vehicle with GPS integration
💰 Start earning within 48 hours

Join as a Partner Today

It’s simple, safe, and rewarding. Your vehicle. Your rules. Your earnings.

PHP 7 Fundamental Tutorial for Beginners – PHP Math Operations

Performing Math Operations

PHP has many built-in functions that help you do anything from simple addition or subtraction to advanced computation.

Example:

Each math operation has a certain precedence level; Multiplication and division are usually done before addition and subtraction. However, parentheses can change this precedence; Sentences enclosed within parentheses are always evaluated, regardless of prior level of operation, as in the following example.

Example:

In the following section we’re going to look at some built-in PHP functions that are most frequently used in performing mathematical operations.

Find the Absolute Value of a Number

The absolute value of an integer or float can be found with the abs () function, as shown in the following Example:

As you can see if the given number is negative or not, the valued return is positive. But, if the number is positive, this function only returns the number.

Round a Fractional Value Up or Down

The ceiling () function can be used to round a fractional value to the next highest integer value, while the floor () function can be used to round a fractional value to the next lowest integer value, As shown in the following Example:

Find the Square Root of a Number

You can use the sqrt () function to find the square root of a positive number. This function returns a special value NAN for negative numbers.

Generate a Random Number

The rand () function can be used to generate a random number. You can optionally specify a range by passing minimum, maximum arguments,

Example

If the rand () function is called without optional minimum, maximum arguments, it returns a pseudo dimensional number between 0 and getrandmax (). The getrandmax () function shows the largest possible random value, which is only 32767 on the Windows platform. Therefore, if you need a range larger than 32767, you can specify only minimum and maximum arguments.

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.