Malhar Lathkar

Malhar Lathkar

103 Articles Published

Articles by Malhar Lathkar

103 articles

PHP compression Stream Wrappers

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

In PHP, compression stream wrappers provide an efficient way to handle compressed files directly through filesystem functions. The main compression wrappers are compress.zlib://, compress.bzip2://, and zip://. compress.zlib:// Wrapper This wrapper works similar to the gzopen() function but can be used with standard filesystem functions like fread(), file_get_contents(), and file_put_contents(). Creating Compressed Files You can create gzip−compressed files directly using the zlib wrapper − Reading Compressed Files To read and decompress the content, use the same wrapper − Using copy() Function The built−in copy() function ...

Read More

PHP ssh2://

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

The ssh2:// wrapper in PHP provides secure access to remote resources using the libssh2 library. It enables shell access, remote execution, tunneling, file transfer, and SCP operations through cryptographic transport. Installation Required: The SSH2 extension must be installed from PECL as it's not enabled by default in PHP. Install using: pecl install ssh2 Available SSH2 Wrappers PHP provides several SSH2 wrappers for different operations − ssh2.shell://user:pass@example.com:22/xterm ssh2.exec://user:pass@example.com:22/usr/local/bin/somecmd ssh2.tunnel://user:pass@example.com:22/192.168.0.1:14 ssh2.sftp://user:pass@example.com:22/path/to/filename ssh2.scp://user:pass@example.com:22/path/to/filename Basic Example Here's how to read a remote file using SSH2 SFTP wrapper − ...

Read More

PHP rar://

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

The RAR (Roshal Archive) is a file compression format that supports error recovery and file spanning. PHP supports the use of .RAR files as IO streams through the rar:// stream wrapper. The rar:// wrapper takes the relative or absolute URL encoded path to the RAR archive, with an optional asterisk (*) or hash (#) and an optional URL encoded entry name as stored in the archive. This wrapper can open both files and directories. Installation Required: This wrapper is not enabled by default. You must install the RAR extension from PECL (PHP Extension Community Library) using: pecl ...

Read More

PHP http://

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 447 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 521 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 455 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 389 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 289 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 724 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 692 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
Showing 1–10 of 103 articles
« Prev 1 2 3 4 5 11 Next »
Advertisements