ScriptFUSION\Porter\Type\StringType::endsWith PHP Method

endsWith() public static method

public static endsWith ( $string, $end )
    public static function endsWith($string, $end)
    {
        // Needle cannot be found if needle is longer than haystack.
        if (($offset = strlen($string) - strlen($end)) >= 0) {
            return strpos($string, $end, $offset) === $offset;
        }
        return false;
    }

Usage Example

Example #1
0
 public function testEndsWith()
 {
     self::assertTrue(StringType::endsWith('foo', 'oo'));
     self::assertTrue(StringType::endsWith('foo', 'foo'));
     self::assertFalse(StringType::endsWith('foo', 'f'));
     self::assertFalse(StringType::endsWith('f', 'foo'));
 }