Google News
logo
PHP Program to Create different variables
Here is an example of how to create different variables in PHP :
Program :
<?php
	// This is a PHP program that creates different variables
	$var1 = "Hello, World!"; // A string variable
	$var2 = 42; // An integer variable
	$var3 = 3.14; // A float variable
	$var4 = true; // A boolean variable
	$var5 = null; // A null variable
	
	// Print the values of the variables to the screen
	echo $var1 . "<br>";
	echo $var2 . "<br>";
	echo $var3 . "<br>";
	echo $var4 . "<br>";
	echo $var5 . "<br>";
?>
Output :
Hello, World!
42
3.14
1
In this code, five different variables are created :

* `$var1` is a string variable that contains the value "Hello, World!".

* `$var2` is an integer variable that contains the value 42.

* `$var3` is a float variable that contains the value 3.14.

* `$var4` is a boolean variable that contains the value true.

* `$var5` is a null variable that has no value assigned to it.

After the variables are created, their values are printed to the screen using the `echo` command. Note that the `<br>` tag is used to add a line break after each value, which makes the output easier to read.

In PHP, variables can be created with a wide range of data types, including strings, integers, floats, booleans, and null values. Variables are created using the dollar sign (`$`) followed by the variable name, and values can be assigned to variables using the assignment operator (`=`).