Skip to Content
Learning PHP
book

Learning PHP

by David Sklar
April 2016
Beginner content levelBeginner
550 pages
9h 40m
English
O'Reilly Media, Inc.
Content preview from Learning PHP

Chapter 2. Data: Working with Text and Numbers

PHP can work with different types of data. In this chapter, you’ll learn about individual values such as numbers and single pieces of text. You’ll learn how to put text and numbers in your programs, as well as some of the limitations the PHP engine puts on those values and some common tricks for manipulating them.

Most PHP programs spend a lot of time handling text because they spend a lot of time generating HTML and working with information in a database. HTML is just a specially formatted kind of text; and information in a database, such as a username, a product description, or an address, is a piece of text, too. Slicing and dicing text easily means you can build dynamic web pages easily.

In Chapter 1, you saw variables in action, but this chapter teaches you more about them. A variable is a named container that holds a value. The value that a variable holds can change as a program runs. When you access data submitted from a form or exchange data with a database, you use variables. In real life, a variable is something such as your checking account balance. As time goes on, the value that the phrase “checking account balance” refers to fluctuates. In a PHP program, a variable might hold the value of a submitted form parameter. Each time the program runs, the value of the submitted form parameter can be different. But whatever the value, you can always refer to it by the same name. This chapter also explains in more detail what ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning PHP 5

Learning PHP 5

David Sklar
Learning PHP 7

Learning PHP 7

Antonio L Zapata (GBP)
Advanced PHP Programming

Advanced PHP Programming

George Schlossnagle

Publisher Resources

ISBN: 9781491933565Errata PageSupplemental Content