Found 1046 Articles for PHP

eval() function in PHP

Arjun Thakur
Updated on 27-Jun-2020 08:56:41

907 Views

The eval() function evaluates a string as PHP code.Syntaxeval(code)Parameterscode − The PHP code to be evaluated.ReturnThe eval() function returns null unless a return statement is called in the code string. Then the value passed to return is returned. if there is a parse error in the code string, eval() returns false.Example Live DemoOutputThe following is the output.This is $one $two! This is Demo text!

die() function in PHP

Ankith Reddy
Updated on 27-Jun-2020 08:57:19

3K+ Views

The die() function prints a message and exits the current script.Syntaxdie(msg)Parametersmsg − The message to write before exiting the script.ReturnThe die() function returns nothing.Example

defined() function in PHP

George John
Updated on 27-Jun-2020 08:57:51

191 Views

The defined() function in PHP checks that constant exists or not.Syntaxdefined(name)Parametersname− The name of constant.ReturnThe defined() function returns true if the constant exists otherwise false.ExampleThe following is an example that checks whether a constant exist. Live DemoOutputThe following is the output.1

define() function in PHP

Chandu yadav
Updated on 27-Jun-2020 08:49:54

672 Views

The define() function defines a constant.Syntaxdefine(const_name,value,case_insensitive)Parametersconst_name − The name of the constant.value − The value of the constant.case_insensitive − The constant name should be case-insensitive.ReturnThe define() function returns true on success or false on failure.ExampleThe following is an example that defines a constant. Live DemoOuptutThe following is the output.This is it!

constant() function in PHP

Arjun Thakur
Updated on 27-Jun-2020 08:50:44

189 Views

The constant() function returns the value of a constant.Syntaxconstant(const)Parametersconst − The name of the constant to checkReturnThe constant() function returns the value of a constant and NULL if the constant is not defined.ExampleThe following is an example that defines a constant. Live DemoOutputThe following is the output.This is it!

FILTER_CALLBACK constant in PHP

Ankith Reddy
Updated on 27-Jun-2020 08:51:17

83 Views

The FILTER_CALLBACK constant calls a user defined function to filter the value.ReturnThe FILTER_CALLBACK constant does not return anything.ExampleThe following is an example that converts the case of a string. Here, existing function in PHP is taken. Live DemoOutputThe following is the output.demo text!

FILTER_SANITIZE_URL constant in PHP

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

295 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

120 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

273 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

529 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?"

Advertisements