str_starts_with

Supported Versions: PHP 8
Checks if a string starts with a given substring
<?php str_starts_with(string $haystack, string $needle): bool
<?php     {

        $key = $this->app['config']['app.key'];



        if (str_starts_with($key, 'base64:')) {

            $key = base64_decode(substr($key, 7));

        }
<?php     public function validAuthenticationResponse($request, $result)

    {

        if (str_starts_with($request->channel_name, 'private')) {

            $signature = $this->generateAblySignature(

                $request->channel_name, $request->socket_id

            );
<?php     public function normalizeChannelName($channel)

    {

        if ($this->isGuardedChannel($channel)) {

            return str_starts_with($channel, 'private-')

                        ? Str::replaceFirst('private-', '', $channel)

                        : Str::replaceFirst('presence-', '', $channel);

        }
<?php             $channel = (string) $channel;



            if (Str::startsWith($channel, ['private-', 'presence-'])) {

                return str_starts_with($channel, 'private-')

                    ? Str::replaceFirst('private-', 'private:', $channel)

                    : Str::replaceFirst('presence-', 'presence:', $channel);

            }
<?php     public function validAuthenticationResponse($request, $result)

    {

        if (str_starts_with($request->channel_name, 'private')) {

            return $this->decodePusherResponse(

                $request,

                method_exists($this->pusher, 'authorizeChannel')
<?php             return ProcessUtils::escapeArgument($value);

        });



        if (str_starts_with($key, '--')) {

            $value = $value->map(function ($value) use ($key) {

                return "{$key}={$value}";

            });
<?php             $value = $value->map(function ($value) use ($key) {

                return "{$key}={$value}";

            });

        } elseif (str_starts_with($key, '-')) {

            $value = $value->map(function ($value) use ($key) {

                return "{$key} {$value}";

            });
<?php     public static function validate($cookieName, $cookieValue, array $keys)

    {

        foreach ($keys as $key) {

            $hasValidPrefix = str_starts_with($cookieValue, static::create($cookieName, $key));



            if ($hasValidPrefix) {

                return static::remove($cookieValue);
<?php             ->map(fn ($segment) => $this->wrapJsonPathSegment($segment))

            ->join('.');



        return "'$".(str_starts_with($jsonPath, '[') ? '' : '.').$jsonPath."'";

    }
<?php     {

        $prefix = $connection->getTablePrefix();



        return str_starts_with($table, $prefix)

            ? substr($table, strlen($prefix))

            : $table;

    }
<?php     protected function isNestedUnder($relation, $name)

    {

        return str_contains($name, '.') && str_starts_with($name, $relation.'.');

    }
<?php         return empty($this->getFillable()) &&

            ! str_contains($key, '.') &&

            ! str_starts_with($key, '_');

    }
<?php     protected function isCustomDateTimeCast($cast)

    {

        return str_starts_with($cast, 'date:') ||

                str_starts_with($cast, 'datetime:');

    }
<?php     protected function isCustomDateTimeCast($cast)

    {

        return str_starts_with($cast, 'date:') ||

                str_starts_with($cast, 'datetime:');

    }
<?php     protected function isImmutableCustomDateTimeCast($cast)

    {

        return str_starts_with($cast, 'immutable_date:') ||

                str_starts_with($cast, 'immutable_datetime:');

    }