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
IntroductionThe global predefined variable $_FILES is an associative array containing items uploaded via HTTP POST method. Uploading a file requires HTTP POST method form with enctype attribute set to multipart/form-data.$HTTP_POST_FILES also contains the same information, but is not a superglobal, and now been deprecatedThe _FILES array contains following properties −$_FILES['file']['name'] - The original name of the file to be uploaded.$_FILES['file']['type'] - The mime type of the file.$_FILES['file']['size'] - The size, in bytes, of the uploaded file.$_FILES['file']['tmp_name'] - The temporary filename of the file in which the uploaded file was stored on the server.$_FILES['file']['error'] - The error code associated with this file upload.Following ... Read More
Introduction$_ENV is another superglobal associative array in PHP. It stores environment variables available to current script. $HTTP_ENV_VARS also contains the same information, but is not a superglobal, and now been deprecated.Environment variables are imported into global namespace. Most of these variables are provided by the shell under which PHP parser is running. Hence, list of environment variables may be different on different platforms.This array also includes CGI variables in case whether PHP is running as a server module orCGI processor.PHP library has getenv()function to retrieve list of all environment variables or value of a specific environment variablegetenvFollowing script displays values ... Read More
IntroductionWhen a PHP script is run from command line, $argv superglobal array contains arguments passed to it. First element in array $argv[0] is always the name of script. This variable is not available if register_argc_argv directive in php.ini is disabled.$argvFollowing script is executed from command line.Example Live DemoOutputarray(1) { [0]=> string(8) "main.php" }In another example as follows, addition of command line arguments is performedExampleOutputC:\xampp\php>php test1.php 10 20 addition = 30
IntroductionThis superglobal variable is available when a PHP script is run from command line (and not when executed from HTTP server's document root). It is an integer that corresponds to number of command line arguments passed to current script. As script's filename has to be entered in command line, minimumn value of $argc is 1. This variable is not available if register_argc_argv directive in php.ini is disabled.$argcFollowing script is expected to be run from command line with 3 arguments including name of scriptExample Live DemoOutputThis script is run with invalid number of argumentsC:\xampp\php>php test1.php 1 2 3 invalid number of argumentsThis script ... Read More
IntroductionWith Weak references, it is possible to retain a reference to an object which does not prevent the object from being destroyed. Implementing cache like structures can be done by Weak reference.A weak reference is similar to a normal reference, except that it doesn’t prevent the garbage collector from collecting the object. If strong references to that object are not found, it will be immediately removed frommemory. This way it is possible to implement most of the benefits of a cache, with no memory issues.WeakReference class has been introduced in PHP 7.4. Before this version, same effect used to be ... Read More
IntroductionTraversable is an abstract interface, hence it can not be directly implemented by any class. Generally, Iterator or IteratorAggregate interfaces, which extend Traversable, are used to check if implementing class is traversable using foreach construct in PHP.Certain built-in classes that implement this interface can be used in foreach and need not implement iterator interfaces. Since Traversable is an abstract interface, it doesn't have any methods in it.SyntaxTraversable { // }When implementing IteratorAggregate or Iterator interface which extends Traversable, they must be listed before its name in the implements clause.
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP