TestPHPLan.php 941 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. class TestPHPLan extends TestCase
  4. {
  5. public function testSlice()
  6. {
  7. $specs = ["red", "green", "blue", "yellow", "brown"];
  8. $count = count($specs);
  9. for ($length = 1; $length < $count; $length++)
  10. {
  11. $low = array_slice($specs,0,$length);
  12. $high = array_slice($specs,$length);
  13. }
  14. }
  15. public function testFS()
  16. {
  17. $str_ends_with = function (string $haystack, string $needle): bool
  18. {
  19. if ('' === $needle || $needle === $haystack) {
  20. return true;
  21. }
  22. if ('' === $haystack) {
  23. return false;
  24. }
  25. $needleLength = strlen($needle);
  26. return $needleLength <= strlen($haystack) && 0 === substr_compare($haystack, $needle, -$needleLength);
  27. };
  28. $a = $str_ends_with('huoshenguo','fs');
  29. $b = 1;
  30. }
  31. }