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
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
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
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
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
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
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
Carrier Sense Multiple Access (CSMA) is a network protocol for carriertransmission that operates in the Medium Access Control (MAC) layer. It senses or listens whether the shared channel for transmission is busy or not, and transmits if the channel is not busy. Using CMSA protocols, more than one users or nodes send and receive data through a shared medium that may be a single cable or optical fiber connecting multiple nodes, or a portion of the wireless spectrum.Working PrincipleWhen a station has frames to transmit, it attempts to detect presence of the carrier signal from the other nodes connected to ... Read More
We have a Trie, and when a user enters a character, we have to show the matching string the Trie. This feature we call it as auto-completion. For example, if a Trie contains "xyzzzz, ""xyz, " "xxxyyxzzz" and when the user enter xy, then we have to show them xyzzzz, xyz, etc.., Steps to achieve the result.Search for the string using the standard Trie algorithm.If the string is not present, then return -1.If the string is present and is the end of a word in Trie, then print the string.If the matching string doesn't have any node, then return.Else print ... Read More
In this tutorial, we are going to learn about the SlugField in Django.SlugFieldSlugField is a way to generate a URL using the data which we already have. You can generate URL using your title of the post or page. Let's see one detailed example.Let's say we have an article with name This is from Tutorialspoint with id = 5. Then we can have URL as www.tutorialspoint.com/posts/5/. It's difficult for the content writers to recognize the article with the previous URL. But, if you have a URL like www.tutorialspoint.com/this-isfrom-tutorialspoint, then it's easy for us to identify the piece. So, SlugField is ... Read More