Re: Where to declare Variables
- From: Scott Johnson <futureshock@xxxxxxx>
- Date: Tue, 05 May 2009 05:45:42 -0700
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.
Thanks
--
************************************
Remove the "x" from my email address
Scott Johnson
futureshockx@xxxxxxx
************************************
.
- Follow-Ups:
- Re: Where to declare Variables
- From: Jerry Stuckle
- Re: Where to declare Variables
- From: Erwin Moller
- Re: Where to declare Variables
- References:
- Where to declare Variables
- From: Scott Johnson
- Re: Where to declare Variables
- From: "j.keßler"
- Where to declare Variables
- Prev by Date: Re: Is it a good idea to design one database(the parameter in mysql_select_db()) with many many tables?
- Next by Date: Odd string behavior
- Previous by thread: Re: Where to declare Variables
- Next by thread: Re: Where to declare Variables
- Index(es):
Relevant Pages
|