PHP Articles

Page 30 of 81

PHP ftp://

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 452 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 386 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 288 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 720 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 690 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 536 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 520 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 585 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

PHP Serializable interface

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

The Serializable interface in PHP allows custom classes to define their own serialization behavior. While PHP's built-in serialize() function can handle most data types, objects of user-defined classes need this interface to control how they are converted to and from string representations. Syntax Serializable { /* Methods */ abstract public serialize() : string abstract public unserialize(string $serialized) : void } Methods Serializable::serialize() − Returns a string representation of the object Serializable::unserialize() − Reconstructs the object from its serialized string representation ...

Read More

PHP Iterable interface

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 1K+ Views

The Iterator interface extends the abstract Traversable interface in PHP. It allows user-defined classes to become iterable using foreach loops. PHP provides many built-in iterators (called SPL iterators) like ArrayIterator, DirectoryIterator, etc. A user class implementing the Iterator interface must implement all its abstract methods. Syntax Iterator extends Traversable { /* Methods */ abstract public current ( void ) : mixed abstract public key ( void ) : scalar abstract public next ( void ) : void abstract public rewind ( void ...

Read More
Showing 291–300 of 802 articles
« Prev 1 28 29 30 31 32 81 Next »
Advertisements