File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
standard /
tests /
strings /
stripslashes_basic.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Feb 21 23:48:04 2012 UTC (12 years, 8 months ago) by
misho
Branches:
php,
MAIN
CVS tags:
v5_4_3elwix,
v5_4_29p0,
v5_4_29,
v5_4_20p0,
v5_4_20,
v5_4_17p0,
v5_4_17,
v5_3_10,
HEAD
php
--TEST--
Test stripslashes() function : basic functionality
--FILE--
<?php
/* Prototype : string stripslashes ( string $str )
* Description: Un-quotes a quoted string
* Source code: ext/standard/string.c
*/
/*
* Testing stripslashes() with quoted strings
*/
echo "*** Testing stripslashes() : basic functionality ***\n";
// Initialize all required variables
$str_array = array( "How's everybody", // string containing single quote
'Are you "JOHN"?', // string with double quotes
'c:\php\stripslashes', // string with backslashes
'c:\\php\\stripslashes', // string with double backslashes
"hello\0world" // string with nul character
);
// Calling striplashes() with all arguments
foreach( $str_array as $str ) {
$str_addslashes = addslashes($str);
var_dump("The string after addslashes is:", $str_addslashes);
$str_stripslashes = stripslashes($str_addslashes);
var_dump("The string after stripslashes is:", $str_stripslashes);
if( strcmp($str, $str_stripslashes) != 0 )
echo "\nError: Original string and string after stripslashes donot match\n";
}
echo "Done\n";
?>
--EXPECTF--
*** Testing stripslashes() : basic functionality ***
string(31) "The string after addslashes is:"
string(16) "How\'s everybody"
string(33) "The string after stripslashes is:"
string(15) "How's everybody"
string(31) "The string after addslashes is:"
string(17) "Are you \"JOHN\"?"
string(33) "The string after stripslashes is:"
string(15) "Are you "JOHN"?"
string(31) "The string after addslashes is:"
string(21) "c:\\php\\stripslashes"
string(33) "The string after stripslashes is:"
string(19) "c:\php\stripslashes"
string(31) "The string after addslashes is:"
string(21) "c:\\php\\stripslashes"
string(33) "The string after stripslashes is:"
string(19) "c:\php\stripslashes"
string(31) "The string after addslashes is:"
string(12) "hello\0world"
string(33) "The string after stripslashes is:"
string(11) "hello world"
Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>