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
Articles by Malhar Lathkar
Page 4 of 11
PHP 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 MorePHP Resources
In PHP, Resource is a special data type that refers to any external resource. A resource variable acts as a reference to external source of data such as stream, file, database etc. PHP uses relevant functions to create these resources. For example, fopen() function opens a disk file and its reference is stored in a resource variable. PHP's Zend engine uses reference counting system. As a result, a resource with zero reference count is destroyed automatically by garbage collector. Hence, memory used by resource data type need not be freed manually. Common Resource Types Various types of ...
Read MorePHP Objects.
In PHP, Object is a compound data type (along with arrays). Values of more than one types can be stored together in a single variable. Object is an instance of either a built-in or user defined class. In addition to properties, class defines functionality associated with data. Primary (scalar) variables, arrays and other objects can be cast to object data type using casting operator. PHP provides stdClass as a generic empty class which is useful for adding properties dynamically and casting. Syntax To declare an object of a class we need to use new statement ? ...
Read MorePHP NULL
In PHP, a variable with no value is said to be of null data type. Such a variable has a value defined as NULL. A variable can be explicitly assigned NULL or its value can be set to null by using the unset() function. Syntax $var = NULL; It is possible to cast a variable of other type to null, although casting null to other type has been deprecated from PHP 7.2. In earlier versions, casting was done using (unset)$var syntax. Example Following example shows how to assign NULL to a variable ? ...
Read MorePHP Iterables
From PHP 7.1 onwards, PHP provides a pseudo-type called iterable that accepts any object implementing the Traversable interface, including arrays. This type declaration ensures parameters can be used with foreach loops or generator functions. Syntax A function can declare iterable as a parameter type to accept values usable in foreach statements. If the parameter doesn't support iteration, PHP throws a TypeError − function functionName(iterable $parameter): iterable { // Function body } Example with Array Parameter This example shows how to use iterable as a function parameter type ? ...
Read MorePHP Floating Point Data Type
In PHP, the float data type represents any number with a decimal point or fractional part. Float values can be written in standard decimal notation or scientific notation using e or E. The size and precision of floats depend on the platform, though precision up to 14 decimal digits is commonly supported. Syntax // Standard decimal notation $var = 5327.496; // Scientific notation (lowercase e) $var1 = 5.327496e3; // Scientific notation (uppercase E) $var2 = 5.327496E3; // Using underscore separator for readability (PHP 7.4+) $var3 = 5_327.496; For better readability, float ...
Read More