Chapter 10. Working with Strings, Dates, and Time


No matter how rich web content becomes, HTML lies behind it all, pushing string-based content out to web browsers. It is no accident, then, that PHP provides many functions with which you can format and manipulate strings. Similarly, dates and times are so much a part of everyday life that it becomes easy to use them without thinking. However, because the quirks of the Gregorian calendar can be difficult to work with, PHP provides powerful tools that make date manipulation an easy task.

Numerous PHP functions are available to you, and this chapter does not begin to cover all of them. However, this chapter does provide a foundation for using some of the basic string, date, and time functions, and an idea of how to begin thinking about using these types of functions in your code. The rule of thumb is this: If you want to transform, manipulate, or display a string, date, or time, don't build your own custom solution without first visiting the PHP Manual because chances are good that a function already exists for your desired task.

In this chapter, you will learn

  • How to format strings

  • How to determine the length of a string

  • How to find a substring within a string

  • How to break a string down into component parts

  • How to remove white space from the beginning or end of a string

  • How to replace substrings

  • How to change the case of a string

  • How to acquire the current date and time

  • How to get information about a date and time

  • How to format date and time information

  • How to test dates for validity

  • How to set dates and times




Sams Teach Yourself PHP, MySQL And Apache All in One
Sams Teach Yourself PHP, MySQL and Apache All in One (3rd Edition)
ISBN: 0672328739
EAN: 2147483647
Year: 2004
Pages: 327

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net