Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by George John
Page 26 of 79
get_browser() function in PHP
The get_browser() function looks up the user's browscap.ini file and returns the capabilities of the user's browser. This function requires the browscap configuration setting in php.ini to be properly configured. Syntax get_browser(user_agent, return_array) Parameters user_agent − Optional. The name of HTTP user agent. If omitted, the current user agent is used. return_array − Optional. If set to true, the function returns an array instead of an object. Return Value The get_browser() function returns an object or array containing information about the user's browser capabilities, or FALSE ...
Read Moreimagesy() function in PHP
The imagesy() function gets the height of an image resource in PHP. It returns the height of the image in pixels or FALSE on errors. Syntax imagesy(image) Parameters image − An image resource created by one of the image creation functions like imagecreatetruecolor(), imagecreatefromjpeg(), etc. Return Value The imagesy() function returns the height of the image in pixels as an integer, or FALSE on failure. Example The following example demonstrates how to get the height of a newly created image − ...
Read Moreimagedashedline() function in PHP
The imagedashedline() function in PHP draws a dashed line on an image resource. This function is part of the GD library and creates a line with alternating filled and empty segments between two specified points. Syntax imagedashedline($image, $x1, $y1, $x2, $y2, $color) Parameters image − An image resource created by functions like imagecreatetruecolor() x1 − Starting point x-coordinate y1 − Starting point y-coordinate x2 − Ending point x-coordinate y2 − Ending point y-coordinate color − Line color created with imagecolorallocate() Return Value Returns TRUE on success or FALSE on failure. ...
Read Moreusleep() function in PHP
The usleep() function delays execution of the current script for a specified number of microseconds. It is useful for creating pauses in script execution or controlling timing in loops. Syntax usleep(microseconds) Parameters microseconds − The number of microseconds to delay the script. One second equals 1, 000, 000 microseconds. Return Value The usleep() function returns void (nothing). Example Here's how to use usleep() to create delays in script execution ? Output The output shows timestamps with delays between them ? ...
Read Moretime_nanosleep() function in PHP
The time_nanosleep() function delays execution of the current script for a specified number of seconds and nanoseconds. This function provides more precise timing control than sleep() by allowing nanosecond-level precision. Syntax time_nanosleep(sec, nsec) Parameters sec − The number of seconds to delay the script. nsec − The number of nanoseconds to delay the script (0 to 999, 999, 999). Return Value The time_nanosleep() function returns true on success, or false on failure. If the delay was interrupted by a signal, it returns an associative array with information about the remaining ...
Read Morepack() function in PHP
The pack() function in PHP converts data into a binary string according to a specified format. This function is useful for creating binary data structures, network protocols, or file formats that require specific byte arrangements. Syntax pack(format, args) Parameters format − The format string specifying how to pack the data. Common format codes include: a − NUL-padded string A − SPACE-padded string ...
Read MoreFILTER_SANITIZE_URL constant in PHP
The FILTER_SANITIZE_URL constant removes all illegal URL characters from a string, keeping only characters that are valid in URLs. This filter is useful for cleaning user input before using it in URL contexts. Allowed Characters The FILTER_SANITIZE_URL filter allows the following characters − $-_.+!*'(), {}|\^~[]`"> Original: https://example.com/search?q=hello world&type=web Sanitized: https://example.com/search?q=helloworld&type=web Key Points Spaces are removed from the input string Non-ASCII characters are stripped out Valid URL characters like ://, ?, &, and = are preserved This filter does not validate URLs, only sanitizes them Conclusion The ...
Read MoreFILTER_SANITIZE_NUMBER_INT constant in PHP
The FILTER_SANITIZE_NUMBER_INT constant removes all characters except digits, plus and minus signs from a string. It's commonly used to clean user input before processing numeric data. Syntax filter_var($value, FILTER_SANITIZE_NUMBER_INT) Parameters The filter_var() function with FILTER_SANITIZE_NUMBER_INT accepts − $value − The string to be sanitized FILTER_SANITIZE_NUMBER_INT − The filter constant that removes illegal characters Return Value Returns a string containing only digits (0-9), plus (+), and minus (-) signs. All other characters are removed. Example Here's how to sanitize a string containing mixed characters ?
Read MoreFILTER_VALIDATE_REGEXP constant in PHP
The FILTER_VALIDATE_REGEXP constant validates a value against a Perl-compatible regular expression. It returns the validated value if the pattern matches, or FALSE on failure. Syntax filter_var($value, FILTER_VALIDATE_REGEXP, $options) Parameters $value − The string to validate $options − An array containing the "regexp" key with the pattern to match against Return Value Returns the validated string if it matches the pattern, or FALSE if validation fails. Example 1: Basic Pattern Matching This example validates an email domain pattern ? Matched String! ...
Read MoreFILTER_VALIDATE_EMAIL constant in PHP
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