addslashes — Quote string with slashes

Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote (), double quote (), backslash (\) and NUL (the NULL byte).

  1. <html>  
  2.  <body>  
  3. style=”color: #000000;”><?php
  4. $str = “Is your name O’reilly?”;
  5. // Outputs: Is your name O\’reilly?
  6. echo addslashes($str style=”color: #007700;”>);
  7. ?>
  8. addcslashes — Quote string with slashes in a C style
  9. Returns a string with backslashes before characters that are listed in charlist parameter.
  10. <?php
  11. echo addcslashes(“zoo[‘.’]”, ‘z..A’);
  12. // output: \zoo[‘\.’]
  13. ?>
  14.  </body>   
  15. </html>  
eXTReMe Tracker