Thursday, April 10, 2008

Code conversion in PHP

    In html, some special character will be encode to
        character                html
         space                    
         "                       "
         &                       &
         <                       &lt;
         >                       &gt;
        
    In html query string, the special character has to be encode to the pattern like %<ASCII>, for instance:
       character                query string
         space                    %20
          &                       %28
          '                       %29
    In PHP, those character has to be escaped by slash(/)
   
    PHP provides a serial methods to convert those.
   
    html_entity_decode()          Converts HTML entities to characters      4
    htmlentities()                 Converts characters to HTML entities     3
    htmlspecialchars_decode()     Converts some predefined HTML entities to characters     5
    htmlspecialchars()             Converts some predefined characters to HTML entities     3
Post a Comment
Google+