Programming Basics
  Home arrow Programming Basics arrow Page 11 - 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 
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 - Strings Formatting


    (Page 11 of 37 )

    As we just saw with the 'printf()' function, formatting can produce clean, consistent output. Formatting functions also provide methods to ensure our basic string comparisons work and they supply us with ways to store our data in a constant fashion. Luckily, PHP provides a vast array of formatting functions. Let's take a high level overview of several formatting functions, and then we will go into specific uses of each.

  • strtolower(string) -This function will convert any given string to lowercase. This can be useful when comparing strings to make sure that the cases are the same.
  • strtoupper '(string) '-This is the complement to the 'strtolower()' function.
  • ucfirst(string) -Any string passed to this function will have the first character capitalized.
  • ucwords(string) -This acts very similar to the 'ucfirst()' function, except that the first character of all words in the string are capitalized.
  • strrev(string) -This function will reverse a string.
  • ltrim(string) -Whitespace at the beginning of a string will be stripped with this function.
  • rtrim(string) -Same as 'ltrim', except it strips whitespace from the end of the string. This function also goes by the name chop()'.
  • trim(string) -This function combines the functionality of 'ltrim' and 'rtrim' and strips whitespace from both the beginning and the end of a string.
  • str_pad(input, pad_length, [,pad_string] [,pad_type]) -With this function, we can pad a string in a variety of ways.
  • str_repeat(input, multiplier) -Given a string and a number of times to display it, this function will repeat the string the given amount of times.
  • nl2br(string) -This function will insert HTML line breaks before each newline in a string.
  • wordwrap(string, [,width [,break [,cut]]]) -We can produce output that is wrapped (or broken) at a certain width. Optionally, we can specify what character to use for the line breaks.
  • chunk_split(string, [,chunklen] [,end]) -This function is very similar to the wordwrap function, with only minor differences.

    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 4 hosted by Hostway
    Stay green...Green IT