1--TEST-- 2Test stripslashes() function : basic functionality 3--FILE-- 4<?php 5/* Prototype : string stripslashes ( string $str ) 6 * Description: Un-quotes a quoted string 7 * Source code: ext/standard/string.c 8*/ 9 10/* 11 * Testing stripslashes() with quoted strings 12*/ 13 14echo "*** Testing stripslashes() : basic functionality ***\n"; 15 16// Initialize all required variables 17$str_array = array( "How's everybody", // string containing single quote 18 'Are you "JOHN"?', // string with double quotes 19 'c:\php\stripslashes', // string with backslashes 20 'c:\\php\\stripslashes', // string with double backslashes 21 "hello\0world" // string with nul character 22 ); 23 24// Calling striplashes() with all arguments 25foreach( $str_array as $str ) { 26 $str_addslashes = addslashes($str); 27 var_dump("The string after addslashes is:", $str_addslashes); 28 $str_stripslashes = stripslashes($str_addslashes); 29 var_dump("The string after stripslashes is:", $str_stripslashes); 30 if( strcmp($str, $str_stripslashes) != 0 ) 31 echo "\nError: Original string and string after stripslashes donot match\n"; 32} 33 34echo "Done\n"; 35?> 36--EXPECTF-- 37*** Testing stripslashes() : basic functionality *** 38string(31) "The string after addslashes is:" 39string(16) "How\'s everybody" 40string(33) "The string after stripslashes is:" 41string(15) "How's everybody" 42string(31) "The string after addslashes is:" 43string(17) "Are you \"JOHN\"?" 44string(33) "The string after stripslashes is:" 45string(15) "Are you "JOHN"?" 46string(31) "The string after addslashes is:" 47string(21) "c:\\php\\stripslashes" 48string(33) "The string after stripslashes is:" 49string(19) "c:\php\stripslashes" 50string(31) "The string after addslashes is:" 51string(21) "c:\\php\\stripslashes" 52string(33) "The string after stripslashes is:" 53string(19) "c:\php\stripslashes" 54string(31) "The string after addslashes is:" 55string(12) "hello\0world" 56string(33) "The string after stripslashes is:" 57string(11) "helloworld" 58Done