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;
?>
var $foo
to be an empty string seems strange. What operations are you doing later that's causing problems?dim d as Integer
? I think what you really need is some encapsulation like functions, classes, etc, so you're out of the global namespace, and then get in the habit of declaring variables at the head of each function/class method.if ($foo == 'blabla')
will prompt an error.extract($_GET)
to create variables and you don't actually know what's been created?