Posts

Showing posts with the label Variable in PHP

Variable in PHP

  Variables are used to store data, like strings of text, numbers, etc. Variable values can change over the course of a script. Here're some important things to know about variables: 1) In PHP, 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. 2) After declaring a variable it can be reused throughout the code. 3) The assignment operator ( = ) used to assign value to a variable. In PHP variable can be declared as:   $var_name = value; <?php // Declaring variables $txt = "Hello World!" ; $number = 10 ; // Displaying variables value echo $txt ; // Output: Hello World! echo $number ; // Output: 10 ?> In the example, we have created two variables where the first one has been assigned with a string value and the second has been assigned with a number. Later we displayed the values of the variables in the browser using the  echo  statement. T...