Malhar Lathkar has Published 189 Answers

PHP $http_response_header

Malhar Lathkar
Published on 22-Sep-2020 10:32:55
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_headerExample<?php file_get_contents("http://localhost"); $arr=$http_response_header; foreach ($arr as $key=>$val) echo "<p>$key=>$val </p>"; ?>OutputBrowser will display result similar to following0=>HTTP/1.1 302 Found 1=>Date: Tue, 08 Sep 2020 14:49:24 GMT 2=>Server: ... Read More

PHP $_REQUEST

Malhar Lathkar
Published on 22-Sep-2020 10:31:14
IntroductionBy default, t he superglobal variable $_REQUEST associative array is collection of contents of $_GET, $_POST and $_COOKIE variables. Settings in php.ini file decide composition of this variable. One of the directives in php.ini is request_order, which decides order in which PHP registers GET, POST and COOKIE variables. The presence and ... Read More

PHP $_POST

Malhar Lathkar
Published on 21-Sep-2020 12:18:24
Introduction$_POST is a predefined variable which is an associative array of key-value pairs passed to a URL by HTTP POST method that uses URLEncoded or multipart/form-data content-type in request.$HTTP_POST_VARS also contains the same information, but is not a superglobal, and now been deprecated.Easiest way to send data to server with POST ... Read More

PHP $_FILES

Malhar Lathkar
Published on 21-Sep-2020 12:14:14
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'] - ... Read More

PHP $_ENV

Malhar Lathkar
Published on 21-Sep-2020 12:11:50
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 ... Read More

PHP $_COOKIE

Malhar Lathkar
Published on 21-Sep-2020 12:10:35
IntroductionThe superglobal $_COOKIE stores variables passed to current script along with HTTP request in the form of cookies.$HTTP_COOKIE_VARS also contains the same information, but is not a superglobal, and now been deprecated.What is a cookie?Cookies are text files stored by a server on the client computer and they are kept of ... Read More

PHP $argv

Malhar Lathkar
Published on 21-Sep-2020 12:08:59
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 Demo<?php var_dump($argv); ?>Outputarray(1) {   ... Read More

PHP $argc

Malhar Lathkar
Published on 21-Sep-2020 12:07:38
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 ... Read More

PHP WeakReference class

Malhar Lathkar
Published on 21-Sep-2020 12:06:03
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 ... Read More

PHP Traversable interface

Malhar Lathkar
Published on 21-Sep-2020 12:04:13
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 ... Read More
Advertisements