How may I initialize multiple PHP variables with a value of zero simultaneously without using an array? I wish to write code that is essentially equivalent to the
If you want to initialize multiple array variables then use
# Initialize multiple array variables with Empty values
$array_1 = $array_2 = $array_3 = array();
# Initialize multiple array variables with Some values in it
list( $array_1, $array_2, $array_3) = array('one','two','three');
# Print value of array variables
var_dump($array_1,$array_2,$array_3);
Output:
*******
string 'one' (length=3)
string 'two' (length=3)
string 'three' (length=5)
If you want to initialize multiple regular variables then use
# Initialize multiple regular variables with values
$a = $b = $c = 'Hello PHP';
echo $a.'
',$b.'
', $c.'
';
Output:
*******
Hello PHP
Hello PHP
Hello PHP