Malhar Lathkar has Published 189 Answers

PHP Context Parameters

Malhar Lathkar
Published on 21-Sep-2020 09:22:40
IntroductionContext parameters allow customization of access to filesystem and other stream wrappers. To configure a stream, PHP has stream_context_set_params() function.Syntaxstream_context_set_params ( resource $stream_or_context , array $params ) : bool$stream_or_context can be any of PHP's supported streams/wrappers/contexts$params is an array with following properties. should be an associative array of the structure ... Read More

PHP MongoDB context options

Malhar Lathkar
Published on 21-Sep-2020 09:20:15
IntroductionPHP can interact with MongoDB database through database extensions. For older versions of PHP, mongo driver can be installed from PECL. This has now been replaced by mongodb driver. Both drivers can be installed using precompiled binaries for Linux/Windows/MacOS operating systems. Alternately, manual installation can be done from source tarball ... Read More

PHP HTTP context options

Malhar Lathkar
Published on 21-Sep-2020 09:15:45
IntroductionGiven below is the list of context options for http:// and https:// transportsmethodHTTP method supported by the remote server. Defaults to GET.headerAdditional headers to be sent during request.user_agentValue to send with User-Agent: header. By default the user_agent php.ini setting is used.contentAdditional data to be sent after the headers. Typically used with ... Read More

PHP FTP context options

Malhar Lathkar
Published on 21-Sep-2020 09:03:48
IntroductionContext options for http:// and https:// transports are listed below −overwriteAllow overwriting of already existing files on remote server while uploading only.resume_posFile offset at which to begin transfer. Applies for downloading only.Defaults to 0 (Beginning of File).proxyProxy FTP request via http proxy server. Applies to file read operations only. Ex −tcp:// ... Read More

PHP variable Variables

Malhar Lathkar
Published on 19-Sep-2020 15:10:15
IntroductionIn PHP, it is possible to set variable name dynamically. Such a variable uses value of an existing variable as name. A variable variable is defined with two $ signs as prefixExample Live Demo<?php $var1="xyz"; //normal variable $$var1="abcd";//variable variable echo $var1 . "\n"; echo $$var1 . "\n"; echo "{$$var1} $xyz"; ?>OutputThis ... Read More

PHP Variable Scope

Malhar Lathkar
Published on 19-Sep-2020 15:08:13
IntroductionIn programming, scope refers to the extentto which a variable is accessible. Generally, a simple PHP script (without any constructs such as loop, function etc.) has a single scope, in the sense, a variable is available througout the program from the point of definition onwards.Variable in a main script is ... Read More

PHP Predefined Variables

Malhar Lathkar
Published on 19-Sep-2020 15:06:13
IntroductionAny PHP script has access to a number of predefined variables. However, many of them are dependent on web server software, PHP version and other factors. Some of these variables are not available for a script running in command line mode. The $GLOBALS variable stores references of all globally available ... Read More

PHP Variables from External Sources

Malhar Lathkar
Published on 19-Sep-2020 15:04:34
IntroductionPHP's variable namespace is populated by external sources such as HTML form elements, cookies and screen coordinates of image submit buttonHTML form elementsWhen a web page submits data in its HTML form to a PHP script, it is automatically made available to the script in the form of $_POST, $_GET ... Read More

PHP Variable Basics

Malhar Lathkar
Published on 19-Sep-2020 15:01:23
IntroductionName of a variable in PHP starts with a $ sign. It is followed by either a letter (A-Z either upper or lowe case) or underscore, and then there may be any number of letters, digits or underscores. Name of variable in PHP is case sensitive.Syntax//valid variables $var=10; $VAR="Hello"; //different ... Read More

PHP Constants

Malhar Lathkar
Published on 19-Sep-2020 14:59:10
IntroductionConstants are represented literally in an assignment expression such as $x=10 or $name="XYZ" where 10 and XYZ are numeric and string constants assigned to variables. In PHP, it is possible to define a constant with a user defined identifier with the help of define() functionSyntaxdefine ( string $name , mixed ... Read More