<?php
echo '<span style="font-size:10px">'; // add styles as style attribute
echo 'test';
echo '</span> ';
echo '<p style="font-size:20px">';
echo $title = $_POST['text'];
echo "</p>";
?>
In PHP, all variable names begin with a dollar sign ($). The $ is followed by an
alphabetic character or an underscore, and optionally followed by a sequence of
alphanumeric characters and underscores. There is no limit on the length of a
variable name. Variable names in PHP are case-sensitive. Here are some examples:
$k
$cot
$Sar_name
$_MPS
In PHP, unlike in many other languages, you do not have to explicitly declare variables.
PHP automatically declares a variable the first time a value is assigned to it.
PHP variables are untyped; you can assign a value of any type to a variable.
PHP uses a symbol table to store the list of variable names and their values.
There are two kinds of symbol tables in PHP: the global symbol table, which stores
the list of global variables, and the function-local symbol table, which stores the
set of variables available inside each function.
Dynamic Variables
Sometimes it is useful to set and use variables dynamically. Normally, you assign a variable like this:
$var = "derro";
Now let's say you want a variable whose name is the value of the $var variable. You can do that like this:
$$var = "Jinna";
PHP parses $$var by first dereferencing the innermost variable, meaning that
$var becomes "derro". The expression that's left is $"hello", which is just $derro.
In other words, we have just created a new variable named hello and assigned it
the value "Jinna". You can nest dynamic variables to an infinite level in PHP,
although once you get beyond two levels, it can be very confusing for someone who
is trying to read your code.
echo '<span style="font-size:10px">'; // add styles as style attribute
echo 'test';
echo '</span> ';
echo '<p style="font-size:20px">';
echo $title = $_POST['text'];
echo "</p>";
?>
In PHP, all variable names begin with a dollar sign ($). The $ is followed by an
alphabetic character or an underscore, and optionally followed by a sequence of
alphanumeric characters and underscores. There is no limit on the length of a
variable name. Variable names in PHP are case-sensitive. Here are some examples:
$k
$cot
$Sar_name
$_MPS
In PHP, unlike in many other languages, you do not have to explicitly declare variables.
PHP automatically declares a variable the first time a value is assigned to it.
PHP variables are untyped; you can assign a value of any type to a variable.
PHP uses a symbol table to store the list of variable names and their values.
There are two kinds of symbol tables in PHP: the global symbol table, which stores
the list of global variables, and the function-local symbol table, which stores the
set of variables available inside each function.
Dynamic Variables
Sometimes it is useful to set and use variables dynamically. Normally, you assign a variable like this:
$var = "derro";
Now let's say you want a variable whose name is the value of the $var variable. You can do that like this:
$$var = "Jinna";
PHP parses $$var by first dereferencing the innermost variable, meaning that
$var becomes "derro". The expression that's left is $"hello", which is just $derro.
In other words, we have just created a new variable named hello and assigned it
the value "Jinna". You can nest dynamic variables to an infinite level in PHP,
although once you get beyond two levels, it can be very confusing for someone who
is trying to read your code.