Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
PHP Articles
Page 32 of 81
PHP Socket context options
Access to filesystem and various other stream wrappers can be customized by context options and parameters configured by stream_context_create() and stream_context_set_option() functions. Following list shows various socket context options available for all wrappers that work over sockets, like tcp, http and ftp ? Socket Context Options Option Description bindto Specifies the IP address (either IPv4 or IPv6) and/or the port number used to access the network. (ip:port for IPv4 [ip]:port for IPv6). backlog Limits number of outstanding connections in socket's listen queue. ipv6_v6only Overrides the OS ...
Read MorePHP Phar context options
Phar stands for PHP Archive. All the resources of a certain PHP application or library are packaged in a single .phar file for the purpose of distribution. A phar file can be used as IO stream with phar:// wrapper. Phar Context Options The phar:// wrapper supports several context options for controlling compression and metadata ? compress PHP has predefined constants for defining compression formats ? Constant Value Description Phar::NONE 0x00000000 no compression Phar::COMPRESSED 0x0000F000 bitmask to determine if any compression is present Phar::GZ 0x00001000 ...
Read MorePHP Context Parameters
Context parameters allow customization of access to filesystem and other stream wrappers. To configure a stream, PHP has stream_context_set_params() function. Syntax stream_context_set_params ( resource $stream_or_context , array $params ) : bool Parameters: $stream_or_context − Any of PHP's supported streams/wrappers/contexts $params − An associative array of the structure $params['paramname'] = "paramvalue" Context Parameters notification − A user-defined callback to be called whenever a stream triggers a notification. Only for http:// and ftp:// stream wrappers. The notification callback function has the following syntax: stream_notification_callback ( ...
Read MorePHP MongoDB context options
PHP can interact with MongoDB database through database extensions. For older versions of PHP, the mongo driver can be installed from PECL. This has now been replaced by the mongodb driver. Both drivers can be installed using precompiled binaries for Linux/Windows/MacOS operating systems. Alternatively, manual installation can be done from source tarball available on github. In either case, mongo or mongodb extension should be enabled in php.ini settings. The PHP MongoDB extension provides Stream Context Support using the mongodb context. This allows you to register callback functions that are triggered during various MongoDB operations for debugging and monitoring purposes. ...
Read MorePHP HTTP context options
PHP HTTP context options allow you to configure HTTP and HTTPS requests when using stream functions like file_get_contents() or fopen(). These options provide control over request methods, headers, timeouts, and other HTTP-specific behaviors. Available Context Options Option Description method HTTP method supported by the remote server. Defaults to GET. header Additional headers to be sent during request. user_agent Value to send with User-Agent: header. By default the user_agent php.ini setting is used. content Additional data to be sent after the headers. Typically used with POST or PUT requests. ...
Read MorePHP FTP context options
Context options for ftp:// transports allow you to customize FTP operations in PHP. These options control how files are transferred, whether existing files can be overwritten, and how connections are handled. Available Context Options Option Description overwrite Allow overwriting of already existing files on remote server while uploading only resume_pos File offset at which to begin transfer. Applies for downloading only. Defaults to 0 (Beginning of File) proxy Proxy FTP request via http proxy server. Applies to file read operations only. Ex − tcp://squid.example.com:8000 Example − Overwriting ...
Read MorePHP variable Variables
In PHP, variable variables allow you to use the value of one variable as the name of another variable. This is achieved by prefixing a variable with two dollar signs ($$). This feature provides dynamic variable naming capabilities. Syntax The syntax for variable variables uses double dollar signs ? $$variable_name = value; Basic Example Here's how variable variables work with string values ? xyz abcd abcd In this example, $$var1 creates a new variable $xyz because the value of $var1 is "xyz". Limitations with ...
Read MorePHP Variables from External Sources
PHP can receive data from external sources like HTML forms, cookies, and image submit buttons. This data is automatically populated into PHP's superglobal variables for easy access in your scripts. HTML Form Elements When a web page submits data through an HTML form, PHP automatically makes it available through $_POST, $_GET, and $_REQUEST variables. Here's a typical HTML form ? The PHP script can access the submitted data through the $_POST associative array ? ...
Read MorePHP Variable Basics
Variables in PHP are fundamental containers for storing data. A PHP variable name starts with a dollar sign ($), followed by a letter or underscore, and can contain letters, numbers, or underscores. Variable names are case-sensitive. Syntax Here are the rules for valid PHP variable names − // Valid variables $var = 10; $VAR = "Hello"; // Different from $var (case-sensitive) $marks_1 = 67; $_val = 0; // Invalid variables var = 10; // Missing $ sign $4sqr = 16; ...
Read MorePHP String Data Type
In PHP, a string data type is a sequence of characters that can contain any character from the ASCII set. Strings are one of the most commonly used data types in PHP for storing and manipulating text data. PHP provides four different ways to define strings − single quotes, double quotes, heredoc syntax, and nowdoc syntax. Each method has its own characteristics and use cases. Syntax // Single quotes $var = 'Hello World'; // Double quotes $var = "Hello World"; // Heredoc $var = Hello World. Welcome ...
Read More