1. Computing

Addslashes () PHP Function

By

Definition: The addslashes function is used to add in backslashes [\] to data submitted from your forms. This keeps the input MySQL (and other coding languages) friendly. What this means is that addslashes would change I'm hungry into I\'m hungry.

It is phrased as: addslashes($string_data)

Also Known As: Add Slashes
Examples:
 <?php
 $greeting = "Hello, I'm Billy";
 print addslashes($greeting);
 ?>
This would output the string: Hello, I\'m Billy

 <?php
 $said = 'Who said "Live long and prosper"?';
 print addslashes($said);
 ?>
This would output the string: Who said \"Live long and prosper\"?

  1. About.com
  2. Computing
  3. PHP / MySQL
  4. PHP Functions
  5. Addslashes - Add Slashes - Addslashes PHP

©2014 About.com. All rights reserved.