strspn_basic.phpt 1.0 KB

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