Professional Documents
Culture Documents
The $var (single dollar) is a normal variable with the name var that stores any
value like string, integer, float, etc.
The $$var (double dollar) is a reference variable that stores the value of the
$variable inside it.
Example 1
<?php
$x = "abc";
$$x = 200;
echo $x."<br/>";
echo $$x."<br/>";
echo $abc;
?>
O/P
U.P
Lucknow
Capital of U.P is Lucknow
Example3
<?php
$name="Cat";
${$name}="Dog"; // $Cat="Dog"
${${$name}}="Monkey"; // $$Cat = "Monkey" or $Dog = Monkey
echo $name. "<br>"; // Cat
echo ${$name}. "<br>"; // Dog
echo $Cat. "<br>"; // Dog
echo ${${$name}}. "<br>"; // Monkey
echo $Dog. "<br>"; // monkey
?>
Now we have printed the values as $name, ${$name}, $Cat, ${${$name}} and $Dog.
=============
PHP Operators
PHP Operator is a symbol i.e used to perform operations on operands. In simple
words, operators are used to perform operations on variables or values. For
example:
Arithmetic Operators
Assignment Operators
Bitwise Operators
Comparison Operators
Incrementing/Decrementing Operators
Logical Operators
String Operators
Array Operators
Type Operators
Execution Operators
Error Control Operators
We can also categorize operators on behalf of operands. They can be categorized in
3 forms:
Assignment Operators
The assignment operators are used to assign value to different variables. The basic
assignment operator is "=".
<?php
//class declaration
class Developer
{}
class Programmer
{}
//creating an object of type Developer
$charu = new Developer();
Charu is a developer.
bool(true) bool(false)
Execution Operators
PHP has an execution operator backticks (``). PHP executes the content of backticks
as a shell command. Execution operator and shell_exec() give the same result.