4 Using Numbers

Chapter 2, “Variables,” loosely discussed the different types of variables, how to assign values to them, and how they’re generally used. In this chapter, you’ll work specifically with number variables—both integers (whole numbers) and floating-point numbers (aka floats or decimals).

The chapter begins by creating an HTML form that will be used to generate number variables. Then you’ll learn how to perform basic arithmetic, how to format numbers, and how to cope with operator precedence. The last two sections of this chapter cover incrementing and decrementing numbers and generating random numbers. Throughout the chapter, you’ll also find mentions of other useful number-related PHP functions.

Creating the Form

Most ...

Get PHP for the Web: Visual QuickStart Guide, Third Edition 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.