Found 34494 Articles for Programming

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!

Sorting collection of String and StringBuffer in Java

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

597 Views

In order to sort in Java as we know we can use either Comparable or Comparator interfaces in which we could also define our custom logic to sort.One of the approach to sort is to add the entity in TreeSet or TreeMap which would sort the entries as internally they also uses the comparable interface. Now String class in Java internally implements comparable interface so whenever we add string to a tree set or map it uses comparable logic of string class and sort the input entry strings.But String buffer do not have the implementation of comparable interface so ... Read More

FILTER_VALIDATE_INT constant in PHP

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

738 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)

FILTER_VALIDATE_EMAIL constant in PHP

George John
Updated on 27-Dec-2019 10:17:35

318 Views

The FILTER_VALIDATE_EMAIL() constant validates an email address.ReturnThe FILTER_VALIDATE_EMAIL() does not return anything.Example Live DemoOutputThe following is the output.examplee@demo.com = valid email address

FILTER_VALIDATE_BOOLEAN constant in PHP

Chandu yadav
Updated on 27-Dec-2019 10:15:03

257 Views

The FILTER_VALIDATE_BOOLEAN constant validates value as a boolean option.ReturnThe FILTER_VALIDATE_BOOLEAN constant returns TRUE for "1", "true", "on" and "yes". It returns FALSE for "0", "false", "off" and "no" otherwise, NULL.Example Live DemoOutputThe following is the output.bool(true)ExampleLet us see another example.OutputHere is the output.bool(false)

filter_var() function in PHP

Ankith Reddy
Updated on 27-Dec-2019 10:13:34

374 Views

The filter_var() function is used to filter a variable with a specified filter.Syntaxfilter_var(variable, filter, options)Parametersvariable − The name of variable.filter − The name of filter to get ID.options − Specifies options to use.ReturnThe filter_var() function returns filtered data on success, or false on failure.Example Live Demo

filter_var_array() function in PHP

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

454 Views

The filter_var_array() function is used to filter multiple variables. Syntax filter_var_array(arrayname, parameters) Parameters arrayname − An array to filter the data. parameters − It specifies an array of filter arguments. Return The filter_var_array() function returns an array of values of the requested variables on success or false on failure. Example Live Demo The following is the output. Array ( [stname] => Jack [stmarks] => 95 [stemail] => jack@abcde.com )

filter_list() function in PHP

Chandu yadav
Updated on 27-Dec-2019 10:12:05

361 Views

The filter_list() function is used to list all supported filters.Syntaxfilter_list()ReturnThe filter_list() function returns an array of filters available. It returns an empty array if there are no filters.Example Live DemoOutputThe following is the output.int257 boolean258 float259 validate_regexp272 validate_domain277 validate_url273 validate_email274 validate_ip275 validate_mac276 string513 stripped513 encoded514 special_chars515 full_special_chars522 unsafe_raw516 email517 url518 number_int519 number_float520 magic_quotes521 callback1024

filter_input_array() function in PHP

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

400 Views

The filter_input_array() function gets names of external variables and filters them optionally. Syntax filter_input_array(type, arraydefine, add_empty) Parameters type − There are five types of inputs to check i.e. INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV. arraydefine − It specifies an array of filter arguments. It is optional. add_empty − If value is True, it adds missing keys as NULL to the return value. Return The filter_input_array() function returns an array containing the values of the variables on success, or false on failure. Example The following is an example that use the filter_input_array() function to filter POST ... Read More

Advertisements