addslashes_basic.phpt 912 B

1234567891011121314151617181920212223242526272829303132
  1. --TEST--
  2. Test addslashes() function : basic functionality
  3. --FILE--
  4. <?php
  5. /*
  6. * Testing addslashes() with strings containing characters that can be prefixed with backslash
  7. * by the function
  8. */
  9. echo "*** Testing addslashes() : basic functionality ***\n";
  10. // Initialize all required variables
  11. $str_array = array( "How's everybody", // string containing single quote
  12. 'Are you "JOHN"?', // string with double quotes
  13. 'c:\php\addslashes', // string with backslashes
  14. "hello\0world" // string with nul character
  15. );
  16. // Calling addslashes() with all arguments
  17. foreach( $str_array as $str ) {
  18. var_dump( addslashes($str) );
  19. }
  20. echo "Done\n";
  21. ?>
  22. --EXPECT--
  23. *** Testing addslashes() : basic functionality ***
  24. string(16) "How\'s everybody"
  25. string(17) "Are you \"JOHN\"?"
  26. string(19) "c:\\php\\addslashes"
  27. string(12) "hello\0world"
  28. Done