PHP Articles

Page 74 of 81

FILTER_VALIDATE_IP constant in PHP

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 854 Views

The FILTER_VALIDATE_IP constant validates an IP address using PHP's filter_var() function. It checks if a given string is a valid IPv4 or IPv6 address format. Syntax filter_var($value, FILTER_VALIDATE_IP, $flags) Parameters $value − The IP address string to validate FILTER_VALIDATE_IP − The validation filter constant $flags − Optional flags to specify validation criteria 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 ...

Read More

FILTER_VALIDATE_FLOAT constant in PHP

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 360 Views

The FILTER_VALIDATE_FLOAT constant validates whether a value is a valid float number. It returns the filtered data on success, or FALSE on failure. Syntax filter_var($value, FILTER_VALIDATE_FLOAT, $flags) Parameters $value − The value to validate as a float $flags (optional) − Additional flags like FILTER_FLAG_ALLOW_THOUSAND Return Value Returns the validated float value on success, or FALSE on failure. Example 1: Basic Float Validation float(291.9) Example 2: Testing Different Values Without flag: bool(false) With thousand separator flag: float(1234.56) ...

Read More

FILTER_VALIDATE_EMAIL constant in PHP

George John
George John
Updated on 15-Mar-2026 470 Views

The FILTER_VALIDATE_EMAIL constant is used with PHP's filter_var() function to validate email addresses. It checks if an email follows the standard email format and returns the email if valid, or false if invalid. Syntax filter_var($email, FILTER_VALIDATE_EMAIL) Return Value Returns the validated email address on success, or false on failure. Example Here's how to validate an email address using FILTER_VALIDATE_EMAIL − example@demo.com = valid email address Testing Invalid Emails Let's test with various invalid email formats − valid@example.com ...

Read More

FILTER_VALIDATE_BOOLEAN constant in PHP

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 418 Views

The FILTER_VALIDATE_BOOLEAN constant validates a value as a boolean option. It's useful when you need to convert string representations of boolean values into actual PHP boolean types. Return Value The FILTER_VALIDATE_BOOLEAN constant returns: TRUE for "1", "true", "on" and "yes" FALSE for "0", "false", "off" and "no" NULL for any other value Syntax filter_var($value, FILTER_VALIDATE_BOOLEAN, $flags) Example 1: Valid TRUE Values This example shows values that return TRUE − bool(true) bool(true) bool(true) Example 2: Valid FALSE Values This example demonstrates ...

Read More

filter_var() function in PHP

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 613 Views

The filter_var() function is used to filter a variable with a specified filter. It provides a convenient way to validate and sanitize data in PHP applications. Syntax filter_var(variable, filter, options) Parameters variable − The value to filter filter − The filter ID that specifies the filter to apply options − Optional flags or options for the filter Return Value The filter_var() function returns the filtered data on success, or FALSE on failure. Example 1: Email Validation This example demonstrates validating an email address using FILTER_VALIDATE_EMAIL ? ...

Read More

filter_list() function in PHP

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 499 Views

The filter_list() function in PHP returns an array of all available filter names that can be used with PHP's filter functions like filter_var() and filter_input(). Syntax filter_list() Parameters This function does not accept any parameters. Return Value The function returns an indexed array containing the names of all available filters. If no filters are available, it returns an empty array. Example Here's how to use filter_list() to display all available filters − Practical Example with Filter IDs You can combine filter_list() with filter_id() to ...

Read More

filter_input() function in PHP

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 681 Views

The filter_input() function gets an external variable by name and optionally filters it using built-in PHP filters. It's commonly used to sanitize and validate user input from forms, URLs, cookies, and server variables. Syntax filter_input(type, var, filtername, options) Parameters type − Specifies the input type. Five constants are available: INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV. var − The name of the variable to filter. filtername − The ID of the filter to apply (e.g., FILTER_VALIDATE_EMAIL, FILTER_SANITIZE_STRING). options − Optional flags or options for the filter. Return Value Returns the filtered ...

Read More

filter_id() function in PHP

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 350 Views

The filter_id() function returns the filter ID of a provided filter name. This is useful when you need to work with filter IDs directly or verify that a filter exists. Syntax filter_id(filtername) Parameters filtername − The name of filter to get the ID from. Return Value The filter_id() function returns filter ID on success or FALSE, if the filter does not exist. Example Here's how to get filter IDs for all available filters ? int = 257 boolean = 258 float = ...

Read More

filter_has_var() function in PHP

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 435 Views

The filter_has_var() function is used to check whether a variable of a specified input type exists or not. This is particularly useful for validating user input from forms, URLs, and other sources. Syntax filter_has_var(type, var) Parameters type − Specifies the input type to check. Available options are: INPUT_GET − GET variables INPUT_POST − POST variables INPUT_COOKIE − COOKIE variables INPUT_SERVER − SERVER variables INPUT_ENV − Environment variables var − The name of the variable to check for existence Return Value Returns true if the variable exists, false ...

Read More

tan() function in PHP

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 115 Views

The tan() function in PHP returns the tangent of a specified value in radians. It's a built-in mathematical function that calculates the ratio of sine to cosine for a given angle. Syntax tan(value) Parameters value − A numeric value representing an angle in radians (float or integer) Return Value The tan() function returns a float representing the tangent of the specified angle. Returns NaN for invalid inputs. Basic Examples Here are some basic examples demonstrating the tan() function ? 01.55740772465491 ...

Read More
Showing 731–740 of 802 articles
« Prev 1 72 73 74 75 76 81 Next »
Advertisements