filter_var

Supported Versions: PHP 5 >= 5.2.0, PHP 7, PHP 8
Filters a variable with a specified filter
<?php filter_var(mixed $value, int $filter = FILTER_DEFAULT, array|int $options = 0): mixed
<?php     protected function unserialize($value)

    {

        if (filter_var($value, FILTER_VALIDATE_INT) !== false) {

            return (int) $value;

        }
<?php         $lastSegment = array_pop($segments);



        if (filter_var($lastSegment, FILTER_VALIDATE_INT) !== false) {

            $i = $lastSegment;

        } elseif (preg_match('/\[(-?[0-9]+)\]$/', $lastSegment, $matches)) {

            $segments[] = Str::beforeLast($lastSegment, $matches[0]);
<?php         return collect($path)->map(function ($attribute) {

            return $this->parseJsonPathArrayKeys($attribute);

        })->collapse()->map(function ($attribute) use ($quote) {

            return filter_var($attribute, FILTER_VALIDATE_INT) !== false

                        ? $attribute

                        : $quote.$attribute.$quote;

        })->all();
<?php     public function boolean($key = null, $default = false)

    {

        return filter_var($this->input($key, $default), FILTER_VALIDATE_BOOLEAN);

    }
<?php     protected function isValidPageNumber($page)

    {

        return $page >= 1 && filter_var($page, FILTER_VALIDATE_INT) !== false;

    }
<?php         Paginator::currentPageResolver(function ($pageName = 'page') use ($app) {

            $page = $app['request']->input($pageName);



            if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {

                return (int) $page;

            }
<?php     {

        $queue = $queue ?: $this->default;



        return filter_var($queue, FILTER_VALIDATE_URL) === false

            ? $this->suffixQueue($queue, $this->suffix)

            : $queue;

    }
<?php     public function isValidUrl($path)

    {

        if (! preg_match('~^(#|//|https?://|(mailto|tel|sms):)~', $path)) {

            return filter_var($path, FILTER_VALIDATE_URL) !== false;

        }



        return true;
<?php     public function split($pattern, $limit = -1, $flags = 0)

    {

        if (filter_var($pattern, FILTER_VALIDATE_INT) !== false) {

            return collect(mb_str_split($this->value, $pattern));

        }
<?php     public function toBoolean()

    {

        return filter_var($this->value, FILTER_VALIDATE_BOOLEAN);

    }
<?php     public function isValid(string $email, EmailLexer $emailLexer): bool

    {

        return is_null($this->flags)

                    ? filter_var($email, FILTER_VALIDATE_EMAIL) !== false

                    : filter_var($email, FILTER_VALIDATE_EMAIL, $this->flags) !== false;

    }
<?php     {

        return is_null($this->flags)

                    ? filter_var($email, FILTER_VALIDATE_EMAIL) !== false

                    : filter_var($email, FILTER_VALIDATE_EMAIL, $this->flags) !== false;

    }
<?php             $id = null;

        }



        if (filter_var($id, FILTER_VALIDATE_INT) !== false) {

            $id = (int) $id;

        }
<?php     public function validateInteger($attribute, $value)

    {

        return filter_var($value, FILTER_VALIDATE_INT) !== false;

    }
<?php     public function validateIp($attribute, $value)

    {

        return filter_var($value, FILTER_VALIDATE_IP) !== false;

    }