Annotation of embedaddon/php/ext/standard/tests/strings/stripslashes_basic.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test 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: 
                     14: echo "*** 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
                     25: foreach( $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: 
                     34: echo "Done\n";
                     35: ?>
                     36: --EXPECTF--
                     37: *** Testing stripslashes() : basic functionality ***
                     38: string(31) "The string after addslashes is:"
                     39: string(16) "How\'s everybody"
                     40: string(33) "The string after stripslashes is:"
                     41: string(15) "How's everybody"
                     42: string(31) "The string after addslashes is:"
                     43: string(17) "Are you \"JOHN\"?"
                     44: string(33) "The string after stripslashes is:"
                     45: string(15) "Are you "JOHN"?"
                     46: string(31) "The string after addslashes is:"
                     47: string(21) "c:\\php\\stripslashes"
                     48: string(33) "The string after stripslashes is:"
                     49: string(19) "c:\php\stripslashes"
                     50: string(31) "The string after addslashes is:"
                     51: string(21) "c:\\php\\stripslashes"
                     52: string(33) "The string after stripslashes is:"
                     53: string(19) "c:\php\stripslashes"
                     54: string(31) "The string after addslashes is:"
                     55: string(12) "hello\0world"
                     56: string(33) "The string after stripslashes is:"
                     57: string(11) "helloworld"
                     58: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>