PHP Variables
|
What is Variables?Variables are used to store information in temporary memory. A variable is assigned a value in one place and then be used throughout your program. A variable does not need to be declared before adding a value to it. PHP automatically converts the variable to the correct data type, depending on its value. Variables in PHP
To make variable in PHP.
<?php $a; $variable; $B_long; $variable_name; $_variable; $_variable_name; $a_variable_name; $variable_Number; $myVariable; $variable_1234; $_1234; ?> Variable in wrong way :
<?php $1234; $$1234; ?> How to store value in VariableThe assignment (=) used to assign value to a variable. When you assign a text value to a variable, put quotes around the value. PHP variable can be creating as: $variable_name = value; Declaring variables
<?php $text = "Hello World!"; $number = 10; $textandnumber = $text . $number; $textandnumberwithspace = $text . " " . $number; ?> Displaying variables value
<?php $text = "Hello World!"; echo $text; // Output: Hello World! $number = 10; echo $number; // Output: 10 $textandnumber = $text . $number; echo $textandnumber; // Output: Hello World!10 $textandnumberwithspace = $text . " " . $number; echo $textandnumberwithspace; // Output: Hello World! 10 ?> |
Share This:
|
Subscribe to:
Posts (Atom)
No comments:
Post a Comment