Re: Where to declare Variables
- From: "j.keßler" <mail@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 05 May 2009 08:07:58 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Scott Johnson wrote:
In most of my code I have used a scheme as follows.Hello,
I have a displayable page with a form.
To minimize the actual php code on this page I include all the
processing code in an included file.
On the form page, the input fields have php variables to display the
data entered if another field failed validation such as:
<input name="summary" type="text" value="<?php echo $summary;?>"/>
Now to prevent notice warning for the variable I set it in the
'included' file:
$summary = '';
Now is this a good way to do this, or is it wiser to do the declaration
in the top of the form page? Where do y'all usually do your
declarations for form value variables?
The reason this came to mind is that in using Zend IDE, it does not
recognize the variables set in an included file if it is used in a
different file and I get warnings about an variable being used before it
is declared. If I declare it at the top of the file it is used the
warning goes away.
I just want to make sure that this just may be a limitation of the IDE
or it is pointing at a good practice.
Thanks
first it is a good practice to declare the variables before using them.
The problem you describe sounds like a Zend IDE problem.
If you really want to make sure you code does not have any warnings or notices
(which is very good) have a look here:
http://www.php.net/manual/en/function.error-reporting.php
then execute your code in the browser or console and check the error messages there.
j.keßler
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkn/174ACgkQE++2Zdc7EtcbngCfa4cOB610og4kSmq2etOImnsu
mfAAoImoagnbHHFcTnbb+3hO5BATAAEM
=0rWh
-----END PGP SIGNATURE-----
.
- Follow-Ups:
- Re: Where to declare Variables
- From: Scott Johnson
- Re: Where to declare Variables
- References:
- Where to declare Variables
- From: Scott Johnson
- Where to declare Variables
- Prev by Date: Re: if/else loops
- Next by Date: Re: Auto online update of files and directories for CMS
- Previous by thread: Where to declare Variables
- Next by thread: Re: Where to declare Variables
- Index(es):
Relevant Pages
|