Found 1046 Articles for PHP

FILTER_SANITIZE_NUMBER_INT constant in PHP

George John
Updated on 27-Jun-2020 08:46:14

493 Views

The FILTER_SANITIZE_NUMBER_INT constant deletes all illegal characters from a number.ReturnThe FILTER_SANITIZE_NUMBER_INT constant does not return anything.Example Live DemoOutputThe following is the output.string(5) "4-5+9"

FILTER_SANITIZE_NUMBER_FLOAT constant in PHP

Ankith Reddy
Updated on 27-Jun-2020 08:48:16

328 Views

The FILTER_SANITIZE_NUMBER_FLOAT constant deletes all illegal characters from a float number.FlagsFILTER_FLAG_ALLOW_FRACTION − Allows fraction separatorFILTER_FLAG_ALLOW_THOUSAND − Allows thousand separatorFILTER_FLAG_ALLOW_SCIENTIFIC − Allows scientific notationReturnThe FILTER_SANITIZE_NUMBER_FLOAT constant does not return anything.ExampleThe following is an example that use FILTER_FLAG_ALLOW_FRACTION flag. Live DemoOutputThe following is the output.string(8) "3-1+2.56"Let us see another example. Here, FILTER_FLAG_ALLOW_THOUSAND flag is used −Example Live DemoOutputHere is the output.string(8) "1-4+25,6"

FILTER_SANITIZE_MAGIC_QUOTES constant in PHP

George John
Updated on 27-Jun-2020 08:34:08

235 Views

The FILTER_SANITIZE_MAGIC_QUOTES constant performs the addslashes() function to a string. It adds backslashes in front of predefined characters i.e. single quote ('), double quote ("), backslash (\), NULL.ReturnThe FILTER_SANITIZE_MAGIC_QUOTES constant does not return anything.Example Live Demo

FILTER_SANITIZE_ENCODED constant in PHP

Chandu yadav
Updated on 27-Jun-2020 08:38:21

195 Views

The FILTER_SANITIZE_ENCODED constant encodes special characters.Flags and OptionsFILTER_FLAG_STRIP_LOW − Remove characters with ASCII value less than 32FILTER_FLAG_STRIP_HIGH − Remove characters with ASCII value greater than 127FILTER_FLAG_ENCODE_LOW − Encode characters with ASCII value less than 32FILTER_FLAG_ENCODE_HIGH − Encode characters with ASCII value greater than 127ReturnThe FILTER_SANITIZE_ENCODED constant does not return anything.ExampleThe following is an example that use FILTER_FLAG_ENCODE_HIGH flag to encode characters with ASCII value > 127Example Live DemoOutputThe following is the output.www.example.comLet us see another example.Example Live DemoOutputHere is the output.example.comRead More

FILTER_SANITIZE_EMAIL constant in PHP

Arjun Thakur
Updated on 27-Jun-2020 08:40:01

306 Views

The FILTER_SANITIZE_EMAIL constant deletes all illegal characters from an email address.ReturnThe FILTER_SANITIZE_EMAIL constant does not return anything.ExampleOutputThe following is the output.abc@demo.com

FILTER_VALIDATE_URL constant in PHP

Ankith Reddy
Updated on 27-Jun-2020 08:24:36

243 Views

The FILTER_VALIDATE_URL constant validates a URL.FlagsFILTER_FLAG_SCHEME_REQUIRED − URL must be RFC compliant.FILTER_FLAG_HOST_REQUIRED − URL must include host name.FILTER_FLAG_PATH_REQUIRED −URL must have a path after the domain name.FILTER_FLAG_QUERY_REQUIRED −URL must have a query string.ReturnThe FILTER_VALIDATE_URL constant does not return anything.Example Live DemoOutputThe following is the output.Valid URL!Let us see another example.Example Live DemoOutputHere is the output.Invalid URL!

FILTER_VALIDATE_REGEXP constant in PHP

George John
Updated on 30-Jul-2019 22:30:23

689 Views

The FILTER_VALIDATE_REGEXP constant validates a value against a Perl-compatible regular expression. Options regexp − The regular expression to validate against. Return The FILTER_VALIDATE_REGEXP constant does not return anything. Example Live Demo The following is the output. Matched String!

FILTER_VALIDATE_IP constant in PHP

Chandu yadav
Updated on 30-Jul-2019 22:30:23

448 Views

The FILTER_VALIDATE_IP constant validates an IP address. Flags FILTER_FLAG_IPV4 − The value must be a valid IPv4 address FILTER_FLAG_IPV6 − The value must be a valid IPv6 address FILTER_FLAG_NO_PRIV_RANGE − The value must not be within a private range FILTER_FLAG_NO_RES_RANGE − The value must not be within a reserved range Return The FILTER_VALIDATE_IP constant does not return anything. Example Live Demo The following is the output. Invalid IP address! Let us see another example. Live Demo Here is the output. Valid IP address!

FILTER_VALIDATE_INT constant in PHP

Arjun Thakur
Updated on 27-Jun-2020 08:30:08

736 Views

The FILTER_VALIDATE_INT constant validates value as integer.Options and flagsmin_range − The minimum integer valuemax_range − The maximum integer valueFILTER_FLAG_ALLOW_OCTAL − Allows octal number valuesFILTER_FLAG_ALLOW_HEX − Allows hexadecimal number valuesReturnThe FILTER_VALIDATE_INT constant does not return anything.Example Live DemoOutputThe following is the output.float(3.5) Integer VariableLet us see another example.Example Live DemoOutputHere is the output.Accepted range!

FILTER_VALIDATE_FLOAT constant in PHP

Ankith Reddy
Updated on 27-Dec-2019 10:21:28

209 Views

The FILTER_VALIDATE_FLOAT constant validates a value as a float number.ReturnThe FILTER_VALIDATE_FLOAT constant does not return anything.Example Live DemoOutputThe following is the output.float(291.9)

Advertisements