PHP Articles

Page 72 of 81

time_nanosleep() function in PHP

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

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 More

sleep() function in PHP

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

The sleep() function delays execution of the current script for a specified number of seconds. This is useful for creating pauses in script execution, rate limiting, or simulating delays. Syntax sleep(seconds) Parameters seconds − The number of seconds to delay the script (integer value). Return Value The sleep() function returns zero on success, or FALSE on failure. Example Here's a simple example demonstrating how sleep() pauses script execution − Start time: 02:54:50 After 2 seconds: 02:54:52 After 3 more seconds: 02:54:55 ...

Read More

show_source() function in PHP

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

The show_source() function in PHP displays the source code of a PHP file with syntax highlighting. This function is useful for code documentation, debugging, or educational purposes where you need to display formatted PHP source code. Syntax show_source(file, return) Parameters file − The file name to display. This can be a relative or absolute path to the PHP file. return − Optional boolean parameter. If set to true, the function returns the highlighted code as a string instead of printing it. Default is false. Return Value If the return parameter ...

Read More

php_strip_whitespace() function in PHP

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

The php_strip_whitespace() function returns PHP source code with stripped comments and whitespace, making it useful for code optimization and analysis. Syntax php_strip_whitespace(file_path) Parameters file_path − The path to the PHP file to be processed. Return Value The php_strip_whitespace() function returns the stripped source code as a string on success, or FALSE on failure. Example Let's create a sample PHP file and then use php_strip_whitespace() to process it ? Now, let's strip the whitespace and comments ? ...

Read More

pack() function in PHP

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

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 More

ignore_user_abort() function in PHP

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

The ignore_user_abort() function sets whether a remote client can abort the running of a script. When enabled, the script continues executing even if the user closes their browser or navigates away from the page. Syntax ignore_user_abort(setting) Parameters setting − Optional boolean parameter. TRUE ignores user aborts (script continues running), FALSE allows user aborts to stop the script (default behavior). Return Value The ignore_user_abort() function returns the previous value of the user-abort setting as an integer (0 for false, 1 for true). Example 1: Getting Current Setting The following ...

Read More

highlight_file() function in PHP

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

The highlight_file() function outputs a file with the PHP syntax highlighted using colors. It's useful for displaying PHP source code in a readable, formatted way on web pages. Syntax highlight_file(file, return) Parameters file − The file name to display. Can be a relative or absolute path to the PHP file. return − Optional boolean parameter. If set to true, the function returns the highlighted code as a string instead of printing it directly. Default is false. Return Value Returns true on success or false on failure when the return parameter ...

Read More

exit() function in PHP

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 1K+ Views

The exit() function in PHP prints a message and terminates the current script execution immediately. It can accept an optional message parameter to display before exiting. Syntax exit(msg) Parameters msg − Optional. The message to display before exiting the script. Can be a string or an integer exit status code. Return Value The exit() function does not return any value as it terminates script execution. Example 1: Basic Usage Here's a simple example showing how exit() works − Before exit Script terminated! Example 2: File Operation with Error Handling The exit() function is commonly used for error handling when operations fail −

Read More

die() function in PHP

Ankith Reddy
Ankith Reddy
Updated on 15-Mar-2026 3K+ Views

The die() function in PHP prints a message and immediately exits the current script. It's commonly used for error handling when critical operations fail. Syntax die(message) Parameters message − Optional. The message to display before terminating the script execution. Return Value The die() function does not return any value as it terminates the script execution. Example 1: Basic Usage Here's a simple example demonstrating die() with a custom message − Script started Script terminated! Example 2: Error Handling with File Operations The die() function is frequently used with file operations for error handling −

Read More

define() function in PHP

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

The define() function defines a constant in PHP. Constants are global variables whose values cannot be changed during script execution. Syntax define(const_name, value, case_insensitive) Parameters const_name − The name of the constant (string). value − The value of the constant (scalar value). case_insensitive − Optional. Whether the constant name should be case-insensitive (default: false). Return Value The define() function returns true on success or false on failure. Examples Basic Example The following example defines a constant and accesses it directly ? ...

Read More
Showing 711–720 of 802 articles
« Prev 1 70 71 72 73 74 81 Next »
Advertisements