Summary
This chapter demonstrated how you can use many of the built-in math functions and operators in conjunction with the advantages of a loosely typed language such as PHP to calculate simple but advanced computations.
We first covered the basic data types and how PHP handles them when assigning and calculating values. Then we discussed the conversion of integers between different base values.
Next, we talked about random numbers and how to build functions to generate random values of floating-point or string data types.
The next two topics were logarithmic and trigonometric functions. These functions have a wide range of usages, but this chapter concentrated on how you can use them to generate charts and calculate the distance between two points on the earth.
Then, we discussed two extensions for handling math on numbers that do not fit into the simple numeric data types of PHP. Finally, we showed how you can create a static math class and use it like you would implement math classes in other languages.
Access provided by Autonomous University of Puebla. Download to read the full chapter text
Chapter PDF
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
Editor information
Rights and permissions
Copyright information
© 2005 Lee Babin, Nathan A. Good, Frank M. Kromann, Jon Stephens
About this chapter
Cite this chapter
(2005). Performing Math Operations. In: Babin, L., Good, N.A., Kromann, F.M., Stephens, J. (eds) PHP 5 Recipes. A-Press. https://doi.org/10.1007/978-1-4302-0070-3_3
Download citation
DOI: https://doi.org/10.1007/978-1-4302-0070-3_3
Publisher Name: A-Press
Print ISBN: 978-1-59059-509-1
Online ISBN: 978-1-4302-0070-3
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books