1--TEST--
2Test addslashes() function : basic functionality
3--FILE--
4<?php
5/* Prototype  : string addslashes ( string $str )
6 * Description: Returns a string with backslashes before characters (single quotes, double quote,
7 *              backslash and nul character) that need to be quoted in database queries etc.
8 * Source code: ext/standard/string.c
9*/
10
11/*
12 * Testing addslashes() with strings containing characters that can be prefixed with backslash
13 * by the function
14*/
15
16echo "*** Testing addslashes() : basic functionality ***\n";
17
18// Initialize all required variables
19$str_array = array( "How's everybody",   // string containing single quote
20                    'Are you "JOHN"?',   // string with double quotes
21                    'c:\php\addslashes',   // string with backslashes
22                    "hello\0world"   // string with nul character
23                  );
24
25// Calling addslashes() with all arguments
26foreach( $str_array as $str )  {
27  var_dump( addslashes($str) );
28}
29
30echo "Done\n";
31?>
32--EXPECTF--
33*** Testing addslashes() : basic functionality ***
34string(16) "How\'s everybody"
35string(17) "Are you \"JOHN\"?"
36string(19) "c:\\php\\addslashes"
37string(12) "hello\0world"
38Done
39