Summary


In this chapter, you have covered some of the functions that enable you to take control of the strings in your PHP scripts. You learned how to format strings with printf() and sprint(). You should be able to use these functions both to create strings that transform data and lay it out. You learned about functions that investigate strings. You should be able to discover the length of a string with strlen(), determine the presence of a substring with strpos(), or extract a substring with substr(). You should be able to tokenize a string with strtok().

You also learned about functions that transform strings. You can now remove white space from the beginning or end of a string with TRim(), ltrim(), or rtrim(). You can change case with strtoupper(), strtolower(), or ucwords(). You can replace all instances of a string with str_replace().

You also learned how to use various PHP functions to perform date- and time-related actions. The time() function gets a date stamp for the current date and time, and you can use geTDate() to extract date information from a timestamp and date() to convert a timestamp into a formatted string. You learned how to create a timestamp using mktime(), and how to test a date for validity with checkdate(). You will learn many more powerful date-related functions in Chapter 16, "Learning Basic SQL Commands," so much so that you may find yourself using MySQL and not PHP for many of your date-related needs.



Sams Teach Yourself PHP MySQL and Apache All in One
Sams Teach Yourself PHP, MySQL and Apache All in One (4th Edition)
ISBN: 067232976X
EAN: 2147483647
Year: 2003
Pages: 333
Authors: Julie Meloni

Similar book on Amazon

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