[thelist] 'not' in PHP and other PHP newbie questions

Richard Livsey richard at livsey.org
Sun Mar 28 13:05:31 CST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Joel D Canfield wrote:
| I want to say
|
|      If there's no 'Address' data, write 'none' for the address
|
| Does this not work?
|
|     If !($Address)
|         {
|            $Address = 'none'
|         }

You probably want 'empty' (http://www.php.net/empty) which checks to see
if the variable exists and not a value that is considered to be empty.
~From the php.net page:

"", 0, "0", NULL, FALSE, array(), var $var;, and objects with empty
properties, are all considered empty. TRUE is returned if var is empty.

if (empty($address))
~   $address = 'none';

Alternatively if you just want to check if the value of $address is not
TRUE, then the following will work:

if (!$address)
~   $address = 'none';

Or to see if the variable has been set/exists then you can use 'isset'
(http://www.php.net/isset)

if (!isset($address))...
~   $address = 'none';

| Also, how do I get PHP to spit back errors instead of a blank page every
| time there's a single syntax error anywhere on the page?

Sounds like you have error reporting off.
http://www.php.net/error_reporting has details on how to turn it on, and
what levels are available.

Hth.

- --
R.Livsey
Incutio Web Developer
www.livsey.org
www.incutio.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAZyH7SIUmK+OkzDERAuI1AKDVgisisZ/8c+f/QGfCwQ+sAZ+A3ACg8VoX
65X/3P0DMFyPan4w4wPKoPI=
=pmDC
-----END PGP SIGNATURE-----


More information about the thelist mailing list