PHP for the World Wide Web: Second Edition written by Larry Ullman
Chapter 5
Using Strings
About Strings
- Creating the HTML Form
- Connecting Strings (Concatenation)
- Combating Magic Quotes
- HTML and PHP
- Encoding and Decoding Strings
- Replacing Parts of a String
- Other String Functions
This chapter dealt with trimming, joining and encoding strings. Remembering that a variable is a container for data and that strings are the most common type of variable, we begin using strings in form responses. Strings are containers of characters, meaning anything from a single letter, code, words, numbers, nonsense to symbols and so on! A string will be printed out in the case of form responses as names, email addresses and the sentences that the user types into the text area. String functions will change the way the output (printed data) will be presented.
The handle_post file went through many alterations, all having to do with string functions, including one which will catch bad words (if you use whatever bad words you want or think possible instead of the generic badword)! If you type 'badword' into the posting below, the string_replace() function will replace it with xxxxx in the handle_post page.
The Form
Complete and submit your posting
Magic Quotes
I now know that Magic Quotes are enabled on my server and so I will need to use the stripslashes() function.
I finally understand the reasoning why! Look at this and notice the slashes in the reply. It is because
I experimented using " " in my reply. Also applies to '.
Need stripslashes??
So, back to the form and put in the stripslashes() function...
but now, I know why! I remember doing this when Krisse and I were in the first PHP 101 and I didn't know why!
It is good to know why!
