I've been coding personal scripts for years in PHP and get used to turn off Error display. I'm about to release some of these scripts and would like to do it the proper way.
The only reason why I turn off error display is to avoid having to test every single var, prior using it, thanks to isset().
So, here is my question:
Is there a better way to declare multiple vars than this ?
<?php // at the begining of my main file if (!isset($foo)) ($foo = ''); if (!isset($bar)) ($bar = ''); if (!isset($ping)) ($ping = ''); if (!isset($pong)) ($pong = ''); // etc. for every single var ?>
Something like this for instance :
<?php var $foo, $bar, $ping, $pong; ?>
$IP = array('111.111. 111.111', '222.222. 222.222', '333.333. 333.333');
Do not declare more than one variable per declaration. Every declaration should be for a single variable, on its own line, with an explanatory comment about the role of the variable. Declaring multiple variables in a single declaration can cause confusion regarding the types of the variables and their initial values.
<?php $foo = $bar = $ping = $pong = ''; ?>
If it's your script and you know which variables where you use, why you want spend recourses to check if the variable was declared before?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With