Re: Where to declare Variables
- From: Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@xxxxxxxxxxxxxxxx>
- Date: Tue, 05 May 2009 15:07:37 +0200
Scott Johnson schreef:
j.keßler wrote:-----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-----
I had a strong idea that it was an IDE shortcoming. As you said I always declare my variables prior to use, it was just where to declare them. Since I don't do design work, only the function coding, I like to minimize code in the displayable page. This way if the design guy changes stuff, he does not have to worry about breaking or integrating a bunch of lines of code.
Are you sure you created a project and added all the used files to that project?
If you just use Zend IDE without a project context, it will only syntax highlight and make suggestions for functionnames and such.
Regards,
Erwin Moller
Thanks
--
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
.
- Follow-Ups:
- Re: Where to declare Variables
- From: Scott Johnson
- Re: Where to declare Variables
- References:
- Where to declare Variables
- From: Scott Johnson
- Re: Where to declare Variables
- From: "j.keßler"
- Re: Where to declare Variables
- From: Scott Johnson
- Where to declare Variables
- Prev by Date: Odd string behavior
- Next by Date: Re: One class per file
- Previous by thread: Re: Where to declare Variables
- Next by thread: Re: Where to declare Variables
- Index(es):
Relevant Pages
|