strcspn_basic.phpt 1019 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. Test strcspn() function : basic functionality
  3. --FILE--
  4. <?php
  5. /* Prototype : proto int strcspn(string str, string mask [, int start [, int len]])
  6. * Description: Finds length of initial segment consisting entirely of characters not found in mask.
  7. If start or/and length is provided, it works like strcspn(substr($s,$start,$len),$bad_chars)
  8. * Source code: ext/standard/string.c
  9. * Alias to functions: none
  10. */
  11. /*
  12. * Testing strcspn() : basic functionality
  13. */
  14. echo "*** Testing strcspn() : basic functionality ***\n";
  15. // Initialise all required variables
  16. $str = "this is the test string";
  17. $mask = "es";
  18. $start = 15;
  19. $len = 30;
  20. // Calling strcspn() with all possible arguments
  21. var_dump( strcspn($str, $mask, $start, $len) );
  22. // Calling strcspn() with three arguments
  23. var_dump( strcspn($str, $mask, $start) );
  24. // Calling strcspn() with default arguments
  25. var_dump( strcspn($str, $mask) );
  26. echo "Done"
  27. ?>
  28. --EXPECTF--
  29. *** Testing strcspn() : basic functionality ***
  30. int(2)
  31. int(2)
  32. int(3)
  33. Done