Programming Articles

Page 1075 of 2547

FILTER_VALIDATE_EMAIL constant in PHP

George John
George John
Updated on 15-Mar-2026 494 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 445 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 637 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 506 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 712 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 374 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 444 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 122 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

sqrt() function in PHP

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

The sqrt() function in PHP returns the square root of a number. It accepts any numeric value and returns a float representing the square root. Syntax sqrt(num) Parameters num − The number for which you want to find the square root. Can be an integer or float. Return Value The sqrt() function returns the square root of the specified number as a float. For negative numbers, it returns NAN (Not a Number). Examples Basic Square Root Finding the square root of a perfect square ? ...

Read More

sinh() function in PHP

Samual Sam
Samual Sam
Updated on 15-Mar-2026 144 Views

The sinh() function returns the hyperbolic sine of a number, which is mathematically equivalent to (exp(num) - exp(-num))/2. This function is commonly used in mathematical calculations involving hyperbolic trigonometry. Syntax sinh(num) Parameters num − The number for which you want to calculate the hyperbolic sine. The value should be in radians. Return Value The sinh() function returns a float representing the hyperbolic sine of the given number. Example 1 Basic usage with simple numeric values ? 0 1.1752011936438 -1.1752011936438 Example ...

Read More
Showing 10741–10750 of 25,466 articles
Advertisements