Found 1060 Articles for PHP

FILTER_SANITIZE_URL constant in PHP

George John
Updated on 27-Jun-2020 08:52:04

465 Views

The FILTER_SANITIZE_URL constant removes all illegal URL characters from a string. It allows the following −$-_.+!*'(),{}|\^~[]`">

FILTER_SANITIZE_STRIPPED constant in PHP

Chandu yadav
Updated on 27-Jun-2020 08:53:04

193 Views

The FILTER_SANITIZE_STRIPPED constant encodes or strips unwanted characters.Options and FlagsFILTER_FLAG_NO_ENCODE_QUOTES − This flag does not encode quotesFILTER_FLAG_STRIP_LOW − Strips characters with ASCII value below 32FILTER_FLAG_STRIP_HIGH − Strips characters with ASCII value above 32FILTER_FLAG_ENCODE_LOW − Encodes characters with ASCII value below 32FILTER_FLAG_ENCODE_HIGH − Encodes characters with ASCII value above 32FILTER_FLAG_ENCODE_AMP − Encodes the & character to &ReturnThe FILTER_SANITIZE_STRIPPED constant does not return anything.Example Live DemoOutputThe following is the output.string(10) "Demo!text!"

FILTER_SANITIZE_STRING constant in PHP

Arjun Thakur
Updated on 27-Jun-2020 08:53:49

390 Views

The FILTER_SANITIZE_STRING constant deletes tags and encodes special characters from a string.FlagsFILTER_FLAG_NO_ENCODE_QUOTES − Do not encode quotesFILTER_FLAG_STRIP_LOW − Removes characters with ASCII value less than 32FILTER_FLAG_STRIP_HIGH − Removes characters with ASCII value greater than 127FILTER_FLAG_ENCODE_LOW − Encodes characters with ASCII value less than 32FILTER_FLAG_ENCODE_HIGH − Encodes characters with ASCII value greater than 127FILTER_FLAG_ENCODE_AMP − Encodes the "&" character to &ReturnThe FILTER_SANITIZE_STRING constant does not return anything.Example Live DemoOutputThe following is the output.Demo!

FILTER_SANITIZE_SPECIAL_CHARS constant in PHP

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

779 Views

The FILTER_SANITIZE_SPECIAL_CHARS constant filter HTML-escapes special characters.FlagsFILTER_FLAG_STRIP_LOW − Strip characters with ASCII value below 32FILTER_FLAG_STRIP_HIGH − Strip characters with ASCII value above 32FILTER_FLAG_ENCODE_HIGH − Encode characters with ASCII value above 32ReturnThe FILTER_SANITIZE_SPECIAL_CHARS constant does not anything.Example Live DemoOutputThe following is the output.string(43) "Favorite Sports is Football & Cricket?"

FILTER_SANITIZE_NUMBER_INT constant in PHP

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

664 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

492 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

317 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

274 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

431 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

466 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!

Advertisements