I usually set all my variables, even if they might not return anything. But now I wonder:
What harm will it make if I echo an empty variable?
eg.
<?php
$a = 'a';
$b = 'b';
if($a==$b)
{
$data = 'Yes they where the same';
};
echo $data;
?>
Why must I do like this?
<?php
$data = ''; // declare varibale
$a = 'a';
$b = 'b';
if($a==$b)
{
$data = 'Yes they where the same';
};
echo $data;
?>
Thanks for your answers!
Extending the question:
What is best practice:
$data = '';
or
$data;
or using
if (isset($data)){
echo $data;
}