From the course: PHP for Non-Programmers
Unlock the full course today
Join today to access over 25,200 courses taught by industry experts.
Numbers: Ints and floats - PHP Tutorial
From the course: PHP for Non-Programmers
Numbers: Ints and floats
- [Instructor] Working with data in PHP can pretty much be broken down into two category types, numbers and non-numbers. Since there's slightly less flexibility with numbers, let's look at them first. Numbers can be represented as whole numbers. For example, 0, -1, 45, 268. And these are called integers. Then there are decimal numbers. For example, 1.0, -2.34, 3.16, and 165.3545. These are called floats. Perhaps the biggest thing to note about using numbers with PHP is they don't require any quotes to use in code. So if you don't use quotes, this tells PHP, "I intend to use this number for calculations." That means we can write something like echo 1 + 1, and PHP will print out 2. That also means we can make variable assignments in the same way. So we could say a gets 1, b gets 2, c gets 2.2 + 3.3, and d gets a + b. In the last assignment, PHP understands that it's going to assign d to whatever a + b equals,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.