Articles on Trending Technologies

Technical articles with clear explanations and examples

PHP Variable Basics

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 414 Views

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 More

PHP String Data Type

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 2K+ Views

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

PHP Resources

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 9K+ Views

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 More

PHP Objects.

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 33K+ Views

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 More

PHP NULL

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 7K+ Views

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 More

PHP Iterables

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 1K+ Views

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 More

PHP Floating Point Data Type

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 935 Views

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

PHP Callbacks/Callables

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 944 Views

Callbacks are functions or methods that can be called dynamically using their names or references. In PHP, any callable entity (functions, methods, closures) can be passed as a parameter and executed later using built-in functions like call_user_func(). Checking if Something is Callable The is_callable() function verifies if an identifier can be called as a function ? bool(true) bool(false) Using Built-in Functions as Callbacks Built-in PHP functions can be called using call_user_func() ? HELLO WORLD 5 User-Defined Function Callbacks Custom functions ...

Read More

PHP Tags

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 9K+ Views

PHP tags are special markers that tell the PHP parser where PHP code begins and ends within a file. These tags allow you to embed PHP code within HTML documents, enabling server-side processing before the content is sent to the browser. Basic PHP Tags The standard PHP opening and closing tags are . All PHP statements must be written between these tags to be processed by the server. Syntax Example Hello World Short Echo Tags PHP provides a shorthand syntax ...

Read More

PHP Escaping From HTML

Malhar Lathkar
Malhar Lathkar
Updated on 15-Mar-2026 1K+ Views

PHP allows you to seamlessly mix PHP code with HTML in a single file. When PHP encounters opening HTML block HTML block Every time the PHP parser encounters an opening tag, it starts executing PHP code until it reaches the closing tag. When PHP code contains conditional statements, the parser determines which blocks to execute or skip. Everything outside PHP tags is treated as HTML and processed by the browser. Basic Example The following example demonstrates PHP code embedded within HTML − ...

Read More
Showing 22291–22300 of 61,297 articles
Advertisements