Found 1060 Articles for PHP

PHP ssh2://

Malhar Lathkar
Updated on 22-Sep-2020 10:50:15

342 Views

IntroductionThe libssh2 library provides access to resources on a remote machine using a secure cryptographic transport. These are shell, remote exec, tunneling, file transfer and SCP. PHP has wrappers for these resources. They are ssh2.shell://, ssh2.exec://, ssh2.tunnel://, ssh2.sftp://, and ssh2.scp:// respectivelyNote that these wrappers are not enabled by default. SSH2 extension available from PECL must be installed.Usagessh2.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/filenamessh2.*// context optionssessionPreconnected ssh2 resource to be reusedsftpPreallocated sftp resource to be reusedmethodsKey exchange, hostkey, cipher, compression, and MAC methods to use callbacksusernameUsername to connect aspasswordPassword to use with password authenticationpubkey_fileName of public key file to use for authenticationprivkey_fileName of private key file ... Read More

PHP rar://

Malhar Lathkar
Updated on 22-Sep-2020 10:48:58

306 Views

IntroductionThe RAR (Roshal Archive) is file compression format that supports error recovery and file spanning. PHP supports use of .RAR files as IO stream. The rar:// is a stream wrapper for RAR streams.rar:// wrapper takes the relative or absolute url encoded path to the RAR archive. An optional (*), or (#) and an optional url encoded entry name, as stored in the archive. This wrapper can open both files and directories.If the pound sign and the entry name part are not included, the root of the archive will be displayed. The usage of the wrapper with RecursiveDirectoryIterator requires the number sign to ... Read More

PHP php://

Malhar Lathkar
Updated on 22-Sep-2020 10:47:26

2K+ Views

IntroductionThe php://wrapper enableaccess to various I/O streams. This includes standard input, output and error streams. In-memory, disk backed and filtered streams are lso accessed with php:// protocol.Standard streamsphp://stdin, php://stdout and php://stderr allow direct access to standard input stream device, standard output stream and error stream to a PHP process respectively. Predefined constants STDIN, STDOUT and STDERR respectively represent these streams.php://inputphp://input allows read-only acess to raw data contained in HTTP request body. Note that same data is available in $HTTP_POST_RAW-DATA variable (which is now deprecated). However, php://input is not available for enctype attribute is set to multipart/form-dataphp://outputThis wrapper represents write-only tream, allowing buffer ... Read More

PHP phar://

Malhar Lathkar
Updated on 22-Sep-2020 10:45:40

1K+ Views

IntroductionThe phar:// stream wrapper is available in all PHP versions after 5.3.0. Phar stands for PHP Archive. It is used to distribute PHP application or library and is executed as a normal PHP file. The phar:// wrapper supports opening file with fopen() for read/write, rename, and directory stream operations opendir() as well as create and remove directories.Phar class allows packaging application resources contained inside a directory in a phar archive. To perform read operations, this archive is put in phar:// wrapperBuilding phar archiveTo begin with, ensure that phar.readonly setting in php.ini is set to 0. Then, create a src folder in which ... Read More

PHP http://

Malhar Lathkar
Updated on 22-Sep-2020 10:44:14

360 Views

IntroductionThe http:// and https:// wrappers enable read only access to resources and files through HTTP procol. When handling virtual name-based host,  host: header is also sent along with user_agent (if configured in php.ini)The http header information is stored in $http_response_header variable. These headers have to be processed to know URL of resource where the document comes from with the help of from: header.HTTPS is supported only if openssl extension is enabled in php.ini settings. Both HTTP and HTTPS connections are read only and don't support writing or copying files.UsageRepresentation of file name in different possible ways is as follows −http://localhost http://example.com http://localhost?name='Ram'&age=20 https://example.com http://username:password@abc.comExampleAbove ... Read More

PHP glob://

Malhar Lathkar
Updated on 22-Sep-2020 10:42:23

433 Views

IntroductionThe 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.ParametersSpecial 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 flagsGLOB_MARK − Adds a slash (a backslash on Windows) to each directory returnedGLOB_NOSORT − Return files as they appear ... Read More

PHP ftp://

Malhar Lathkar
Updated on 22-Sep-2020 10:40:15

393 Views

IntroductionBoth ftp:// and  ftps:// wrappers allow read access to URLs with ftp (and ftps) protocol. New file can also be created using these wrappers. If passive mode ftp support is not possible in the server, connection will fail.Simultaneous read-write operations are not permitted with streams using ftp protocol. If it is required to overwrite existing file, it may be done by specifying overwrite option in context options.The php.ini file has from setting which specifies email ID to be used for unauthenticated FTP connection.If it is set, it is used as anonymous FTP password. It is also possible to have ftp access ... Read More

PHP file://

Malhar Lathkar
Updated on 22-Sep-2020 10:39:17

335 Views

IntroductionVarious URL-style protocols can be used with filesystem functions with the help of corresponding built-in wrappers avalable in PHP. The stream_wrapper_register() function is also there to define custom wrapper.Default wrapper in PHP is file:// and it represents local filesystem. If no other protocol is explicitly used, PHP parser treats it as filesystem wrapper. The filename argument to be given to filesystem functions fopen(),  file_get_contents() etc uses file:// protocol by default.When file name doesn't begin with forward or backward slash, or drive letter in Windows, its path is taken as relative to current directory. However, in fopen() and file_get_contents() functions, file name ... Read More

PHP data://

Malhar Lathkar
Updated on 22-Sep-2020 10:37:59

237 Views

IntroductionThe data URI scheme has been defined in RFC 2397, published in 1998. It provides a mechanism to include in-line data in web page as if it is an external resource. PHP provides data:// wrapper for data URI representation. The data URI is represented as per following syntaxdata:// syntaxdata:[media type][;base64], dataparametersmedia type − Default is text/plainoptional base64 extension base64, separated from the preceding part by a semicolon, ndicating that the data content is binary data, encoded using the Base64 scheme for binary-to-text encoding.The data, separated from the preceding part by a comma (, ). The data is a sequence of zero ... Read More

PHP $http_response_header

Malhar Lathkar
Updated on 22-Sep-2020 10:33:27

640 Views

IntroductionThe superglobal $http_response_header array is populated by HTTP response headers as is the case with get_headers() functions. This array is created in local space of PHP$http_response_headerExampleOutputBrowser will display result similar to following0=>HTTP/1.1 302 Found 1=>Date: Tue, 08 Sep 2020 14:49:24 GMT 2=>Server: Apache/2.4.41 (Win64) OpenSSL/1.0.2s PHP/7.1.32 3=>X-Powered-By: PHP/7.1.32 4=>Location: http://localhost/dashboard/ 5=>Content-Length: 0 6=>Connection: close 7=>Content-Type: text/html; charset=UTF-8 8=>HTTP/1.1 200 OK 9=>Date: Tue, 08 Sep 2020 14:49:24 GMT 10=>Server: Apache/2.4.41 (Win64) OpenSSL/1.0.2s PHP/7.1.32 11=>Last-Modified: Mon, 02 Sep 2019 15:45:31 GMT 12=>ETag: "1d99-59193dc9c3cc0" 13=>Accept-Ranges: bytes 14=>Content-Length: 7577 15=>Connection: close 16=>Content-Type: text/html

Advertisements