Skip to Content
Learning PHP and MySQL
book

Learning PHP and MySQL

by Michele E. Davis, Jon A. Phillips
June 2006
Beginner
376 pages
8h 55m
English
O'Reilly Media, Inc.
Content preview from Learning PHP and MySQL

Chapter 11. Practical PHP

In this chapter, we’ll start working on some of the more common tasks that you’ll perform when writing PHP programs, such as work with strings, display formats for strings, as well as dates and time. We’ll also show you how to work with files that your PHP program creates or reads. Also, we’ll provide an example of how to let a user upload a file and then validate its contents before making it accessible. Uploading files is useful but can be a security risk if files aren’t properly validated.

When building HTML output for web pages, we spend quite a bit of time working with strings. PHP has a rich set of functions for doing all the tasks you may need to change the case of a string. You also need to be able to format dates and times. Performing any sort of addition or subtraction on dates—thanks to quirks such as leap years—can quickly become complicated without a little help from functions specifically designed to work with dates.

String Functions

Because you’re working with essentially two languages that both support manipulating strings, you need to learn about string functions in PHP and MySQL. You may find it more appropriate to modify a string either in a query or in PHP, based on the particular situation. You’re going to learn about the following string operations:

  • Formatting strings for display

  • Calculating the length of a string

  • Changing a string’s case to uppercase or lowercase

  • Searching for strings within strings and returning the position of the match ...

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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Learning PHP, MySQL, and JavaScript

Learning PHP, MySQL, and JavaScript

Robin Nixon
Learning PHP

Learning PHP

David Sklar

Publisher Resources

ISBN: 0596101104Errata Page