iconv_substr_error2.phpt 916 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. Test iconv_substr() function : error conditions - Pass an unknown encoding
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('iconv') or die('skip');
  6. function_exists('iconv_substr') or die("skip iconv_substr() is not available in this build");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : string iconv_substr(string str, int offset, [int length, string charset])
  11. * Description: Returns part of a string
  12. * Source code: ext/iconv/iconv.c
  13. */
  14. /*
  15. * Pass an unknown encoding to iconv_substr() to test behaviour
  16. */
  17. echo "*** Testing iconv_substr() : error conditions ***\n";
  18. $str = 'Hello, world';
  19. $start = 1;
  20. $length = 5;
  21. $encoding = 'unknown-encoding';
  22. var_dump( iconv_substr($str, $start, $length, $encoding));
  23. echo "Done";
  24. ?>
  25. --EXPECTF--
  26. *** Testing iconv_substr() : error conditions ***
  27. Notice: iconv_substr(): Wrong charset, conversion from `unknown-encoding' to `UCS-4LE' is not allowed in %s on line %d
  28. bool(false)
  29. Done