Jump to: navigation, search

Php addslashes

From w3cyberlearnings

Contents

PHP function addslashes

This function adds a backslash to any single quotes, double quotes, backslash, and NULL.

Syntax addslashes

  • string: string to use.
addslashes(string)

Example 1

<?php

$mylist = "I'll want to tell you how to do it";
$mynew_list = addslashes($mylist);
echo $mynew_list;
?>

Output

  • Add slash to I\'ll
I\'ll want to tell you how to do it

Example 2

<?php

$mylist = "\goi\glg\we";
$mynew_list = addslashes($mylist);
echo $mynew_list;
?>

Output

\\goi\\glg\\we

Example 3

<?php

$mylist = 'Quote:"I ever tell you when it is all impossible until you never try it!"';
$mynew_list = addslashes($mylist);
echo $mynew_list;
?>

Output

Quote:\"I ever tell you when it is all impossible until you never try it!\"

Related Functions


Navigation
Web
SQL
MISC
References