CHAPTER 3Performing Math Operations

Math is one of the fundamental elements of most programming languages. Math allows the programmer to perform anything from simple additions to advanced calculations. Even though PHP was designed to create dynamic Hypertext Markup Language (HTML) documents, it has evolved to a general-purpose programming language that includes a strong and flexible math implementation.

The implementation of math in PHP looks very much like the implementation in C. In fact, many of the functions are implemented as simple wrappers around the math functions found in C libraries.

3-1. Numeric Data Types

Working with numbers or numeric data and math functions in PHP is simple. Basically, you have two data types to work with, floating ...

Get PHP 5 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.