Articles on Trending Technologies

Technical articles with clear explanations and examples

PHP http://

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 464 Views

The http:// and https:// wrappers in PHP enable read-only access to resources and files through the HTTP protocol. When handling virtual name-based hosts, the host: header is sent along with user_agent (if configured in php.ini). The HTTP header information is stored in the $http_response_header variable. These headers help identify the URL of the resource where the document originates from using the from: header. HTTPS is supported only if the openssl extension is enabled in php.ini settings. Syntax The HTTP/HTTPS wrapper can be used in different formats − http://localhost http://example.com http://localhost?name='Ram'&age=20 https://example.com http://username:password@abc.com Key ...

Read More

PHP glob://

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 568 Views

The glob:// stream wrapper is available in all PHP versions after 5.3.0. It finds pathnames that match given pattern. Similar purpose is fulfilled by PHP's filesystem function glob() which follows libc glob() rules. Parameters Special Characters * − Matches zero or more characters. ? − Matches exactly one character (any character). [...] − Matches one character from a group of characters. If the first character is !, matches any character not in the group. \ − Escapes the following character, except when the GLOB_NOESCAPE flag is used. Valid Flags GLOB_MARK − Adds ...

Read More

PHP ftp://

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 468 Views

PHP provides built−in support for FTP operations through the ftp:// and ftps:// stream wrappers. These wrappers allow you to read files from FTP servers and create new files using standard PHP file functions. Syntax ftp://[username:password@]server/path/to/file ftps://[username:password@]server/path/to/file Basic Usage Here's how to read a file from an FTP server using the ftp:// wrapper − Creating Files on FTP Server You can create new files on the FTP server using file_put_contents() − Context Options Use stream context to set FTP options like overwrite mode ...

Read More

PHP file://

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 395 Views

The file:// wrapper is PHP's default stream wrapper that represents the local filesystem. When no protocol is explicitly specified, PHP automatically uses the file:// wrapper for filesystem operations like fopen() and file_get_contents(). How file:// Works The file:// wrapper provides access to the local filesystem and supports various operations ? Reading and writing files simultaneously Creating and removing directories Renaming files No restriction by allow_url_fopen directive Path Types You can specify file paths in different ways with the file:// wrapper ? Absolute Path Relative Path ...

Read More

PHP data://

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 300 Views

The data:// wrapper in PHP allows you to embed data directly into your code using the data URI scheme defined in RFC 2397. This is useful for including inline data without external files. Syntax data:[media type][;base64], data Parameters media type − MIME type of the data (default: text/plain) base64 − Optional encoding indicator for binary data data − The actual data content, separated by a comma Example 1: Basic String Encoding This example encodes a string to base64 format and reads it using the data:// wrapper − ...

Read More

PHP $http_response_header

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 753 Views

The $http_response_header superglobal array is automatically populated with HTTP response headers when using HTTP wrapper functions like file_get_contents(). This array is created in the local scope where the HTTP request is made. Syntax The array is automatically created after calling HTTP wrapper functions − file_get_contents($url); // $http_response_header is now available Example Here's how to access HTTP response headers using $http_response_header ? Output The browser will display headers similar to the following − 0 => HTTP/1.1 302 Found 1 => Date: Tue, 08 Sep 2020 14:49:24 ...

Read More

PHP $argc

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 743 Views

The $argc variable is a PHP superglobal that stores the count of command−line arguments passed to a script. It is only available when running PHP scripts from the command line, not through a web server. The minimum value is 1 since the script filename itself counts as an argument. Note: This variable requires the register_argc_argv directive to be enabled in php.ini (enabled by default). Syntax The $argc variable is automatically populated when running PHP from command line ? Example Here's a script that validates the number of command−line arguments ...

Read More

PHP WeakReference class

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 548 Views

PHP's WeakReference class allows you to retain a reference to an object without preventing the garbage collector from destroying it. This is useful for implementing cache-like structures without memory issues, as the object can be freed when no strong references remain. What are Weak References? A weak reference differs from a normal reference because it doesn't prevent garbage collection. When all strong references to an object are removed, the object is immediately destroyed, even if weak references still exist. This enables efficient caching without memory leaks. Syntax WeakReference { /* Methods */ ...

Read More

PHP Traversable interface

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 536 Views

The Traversable interface is PHP's base interface for making objects work with foreach loops. It's an abstract interface that cannot be implemented directly − instead, you implement either Iterator or IteratorAggregate which extend Traversable. Syntax Traversable { // No methods - this is an abstract interface } Using IteratorAggregate The simplest way to make a class traversable is by implementing IteratorAggregate ? Apple Banana Cherry Using Iterator Interface For more control, implement the Iterator interface directly ? ...

Read More

PHP Throwable interface

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 602 Views

In PHP 7, the Throwable interface serves as the base interface for any object that can be thrown using the throw statement, including Error and Exception. Both Error and Exception classes implement this interface, making it possible to catch all throwable objects uniformly. Syntax Throwable { /* Methods */ abstract public getMessage ( void ) : string abstract public getCode ( void ) : int abstract public getFile ( void ) : string abstract public getLine ( ...

Read More
Showing 22261–22270 of 61,297 articles
Advertisements