Programming Basics
  Home arrow Programming Basics arrow Page 17 - PHP Strings Primer
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
JMSL Numerical Library 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PROGRAMMING BASICS

PHP Strings Primer
By: Matt Wade
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2003-07-11

    Table of Contents:
  • PHP Strings Primer
  • The Basics
  • Single Quotes
  • Double Quotes
  • Heredoc
  • Concatenation
  • Displaying Strings
  • echo
  • print
  • printf
  • Strings Formatting
  • Preparing user input for comparisons
  • Capitalization
  • Reversing strings
  • Padding strings
  • Multiple Lines
  • Data Preparation
  • Adding and Removing Slashes
  • Dealing with HTML Tags and Entities
  • Counting
  • Checking password strength
  • Generating Statistics
  • Substrings (and searching)
  • Extracting Substrings
  • Counting Paragraphs
  • Filtering Words
  • Working with email addresses
  • Manually Stripping Tags
  • Password Strength Revisited
  • Handling URLs and Base64-encoding
  • Parsing URLs
  • Encoding for URLs
  • Encoding for Email
  • Hashing
  • Verifying Integrity
  • User Authentication
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    PHP Strings Primer - Data Preparation


    (Page 17 of 37 )

    When we accept input in our applications, we can not expect the data to be in acceptable format. In order to store the data in a database, or even redisplay it to the user, we must take care to ensure that it is stored or displayed as it should be. We can accomplish this by adding backslashes to escape characters, removing HTML tags from the input, and converting special characters into their HTML entity equivalent. Let's, first, take a high level overview of the functions we will cover in this section.

  • addslashes(string) -This function will add a backslash before a single quote, a double quote, a backslash, or the NULL byte.
  • stripslashes(string) -With this function, we can undo what was done with the 'addslashes' function.
  • strip_tags(string) -When we have data from an unknown source, it is helpful to remove any HTML and PHP tags. With this function we can accomplish just that.
  • htmlentities(string [,quote_style]) -Rather than removing the tags as seen with strip_tags, with this function we can change the characters used by the tags to their HTML entity equivalents. This function will change any character that has a HTML entity equivalent into that entity. For an example, a '<' symbol will be changed into '&lt;'
  • htmlspecialchars(string [,quote_style]) -This function is almost identical to the 'htmlentities' function. The only difference is that this function only translates a handful of characters. This includes the ampersand, double quote, less than, and greater than characters.
  • html_entity_decode(string) -After using the previous two functions, we can use this function to undo those translations.

    More Programming Basics Articles
    More By Matt Wade


       · comment
       · really goood work ,it covers all the major string functions.also explained with...
       · test'ng
     

  • PROGRAMMING BASICS ARTICLES

    - Loops and PHP Decision Making
    - Operators, Conditionals, and PHP Decision-Ma...
    - PHP Decision-Making
    - Coding
    - Server Statistics
    - Looping in PHP
    - Cookies in PHP
    - Working with text files
    - Beginning Object Oriented Programming in PHP
    - A Tour of Decision Making Structures in PHP
    - PHP Strings Primer
    - PHP Control Structures
    - Intro to Vim
    - Reading Directorys with PHP
    - An Overview of Arrays in PHP






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway