[lang-ref] ( string_starts_with ) ( php )

<?php
public function testStringStartsWith(): void
{
	// str_starts_with($text, $prefix)
	// PHP 8+
	$text = 'Good morning';
	$s    = 'Good';

	$this->assertTrue(str_starts_with($text, $s));
}
<?php
public function testStringStartsWithAlternative(): void
{
	// substr(...) === $s
	// for older PHP versions
	$text = 'Good morning';
	$s    = 'Good';

	$this->assertTrue(substr($text, 0, strlen($s)) === $s);
}