strstr_variation1.phpt 751 B

1234567891011121314151617181920212223
  1. --TEST--
  2. Test strstr() function : usage variations - complex strings containing other than 7-bit chars
  3. --FILE--
  4. <?php
  5. $string = chr(0).chr(128).chr(129).chr(234).chr(235).chr(254).chr(255);
  6. $stringAsHex = bin2hex($string);
  7. echo "-- Positions of some chars in the string '$stringAsHex' are as follows --\n";
  8. echo bin2hex( chr(128) ) ." => ";
  9. var_dump( bin2hex( strstr($string, chr(128) ) ) );
  10. echo bin2hex( chr(255) ) ." => ";
  11. var_dump( bin2hex( strstr($string, chr(255) ) ) );
  12. echo bin2hex( chr(256) ) ." => ";
  13. var_dump( bin2hex( strstr($string, chr(256) ) ) );
  14. ?>
  15. DONE
  16. --EXPECT--
  17. -- Positions of some chars in the string '008081eaebfeff' are as follows --
  18. 80 => string(12) "8081eaebfeff"
  19. ff => string(2) "ff"
  20. 00 => string(14) "008081eaebfeff"
  21. DONE