Should I care about these errors?
Should I care about these errors?
am 05.11.2009 09:02:27 von Angus Mann
Hi all. I find that when I turn on strict error reporting:
ERROR_REPORTING(E_ALL);
I see all sorts of errors in scripts that otherwise work just fine.
The most common I guess is "Use of undefined constant".
I know where the errors come from and I know how to stop them, but I guess
my question is "Should I bother?" Is there really any any harm if I write:
$price = 100;
without first defining $tennis as a string, or an integer or whatever?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Should I care about these errors?
am 05.11.2009 09:26:04 von Lars Torben Wilson
2009/11/5 Angus Mann :
> Hi all. I find that when I turn on strict error reporting:
> ERROR_REPORTING(E_ALL);
> I see all sorts of errors in scripts that otherwise work just fine.
>
> The most common I guess is "Use of undefined constant".
>
> I know where the errors come from and I know how to stop them, but I guess
> my question is "Should I bother?" Is there really any any harm if I write:
>
> $price = 100;
>
> without first defining $tennis as a string, or an integer or whatever?
$tennis? That's not even mentioned in your example.
In general, yes. In rough, no. Notices tell you where you are making
basic coding mistakes but do not necessarily indicate problem with the
way the code will actually execute. However, from your example, it's
impossible to say whether what you're seeing actually represents a
problem with the code you're writing.
'Undefined constant' notices usually mean you've used an unquoted
string, which will be a problem if, for example, another part of the
code defines a constant with the same name as the unquoted string in
your code.
Pay attention to the notices. Again, your code might execute fine with
notices thrown everywhere, but they often indicate sloppiness which
can come back to bite you in hard-to-debug ways later on.
If you post a more complete example it will be easier to help you.
Regards,
Torben
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Should I care about these errors?
am 05.11.2009 14:36:43 von TedD
At 6:02 PM +1000 11/5/09, Angus Mann wrote:
>but I guess my question is "Should I bother?"
Yes.
Learn to write error free code.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Should I care about these errors?
am 05.11.2009 14:50:40 von Angus Mann
OK...point taken.
On a partly related matter, which of the following is "correct" or "Better"
?
echo("Stuff to display...");
or
echo 'Stuff to display...';
or
echo "Stuff to display...";
or
echo('Stuff to display...');
They all produce the same result, and I do understand the difference between
single and double quotes, but I'm looking for general principles here. Are
there any rules I should follow to help me decide between the choices above?
----- Original Message -----
From: "tedd"
To: "Angus Mann" ;
Sent: Thursday, November 05, 2009 11:36 PM
Subject: Re: [PHP] Should I care about these errors?
> At 6:02 PM +1000 11/5/09, Angus Mann wrote:
>>but I guess my question is "Should I bother?"
>
> Yes.
>
> Learn to write error free code.
>
> Cheers,
>
> tedd
>
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Should I care about these errors?
am 05.11.2009 14:53:51 von Ashley Sheridan
--=-YlneqR12QezOz1TsxXke
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Thu, 2009-11-05 at 23:50 +1000, Angus Mann wrote:
> OK...point taken.
>
> On a partly related matter, which of the following is "correct" or "Better"
> ?
>
> echo("Stuff to display...");
> or
> echo 'Stuff to display...';
> or
> echo "Stuff to display...";
> or
> echo('Stuff to display...');
>
> They all produce the same result, and I do understand the difference between
> single and double quotes, but I'm looking for general principles here. Are
> there any rules I should follow to help me decide between the choices above?
>
>
>
>
> ----- Original Message -----
> From: "tedd"
> To: "Angus Mann" ;
> Sent: Thursday, November 05, 2009 11:36 PM
> Subject: Re: [PHP] Should I care about these errors?
>
>
> > At 6:02 PM +1000 11/5/09, Angus Mann wrote:
> >>but I guess my question is "Should I bother?"
> >
> > Yes.
> >
> > Learn to write error free code.
> >
> > Cheers,
> >
> > tedd
> >
> > --
> > -------
> > http://sperling.com http://ancientstones.com http://earthstones.com
>
>
Essentially they are the same. With the obvious difference of type of
quotes used aside, the use of brackets is just down to preference. I
tend not to use them (mind you, I always use print instead of echo -
goes back to my days of learning to program on a c64) but you may find
that working in a team there is a group coding methodology that everyone
tries to use.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-YlneqR12QezOz1TsxXke--
Re: Should I care about these errors?
am 05.11.2009 15:00:20 von sandortamas
I think, it is better to stick one way, doesn't matter really, which one.
The difference between single and double quotes partly define which one
you'd use, but other times it's better to use the same all time.
Speaking about paranthesises, I'd rather use them, because it makes obvious
that it is a function, and makes it easier to read your code.
SanTa
----- Original Message -----
From: "Angus Mann"
To:
Sent: Thursday, November 05, 2009 2:50 PM
Subject: Re: [PHP] Should I care about these errors?
> OK...point taken.
>
> On a partly related matter, which of the following is "correct" or
> "Better" ?
>
> echo("Stuff to display...");
> or
> echo 'Stuff to display...';
> or
> echo "Stuff to display...";
> or
> echo('Stuff to display...');
>
> They all produce the same result, and I do understand the difference
> between single and double quotes, but I'm looking for general principles
> here. Are there any rules I should follow to help me decide between the
> choices above?
>
>
>
>
> ----- Original Message -----
> From: "tedd"
> To: "Angus Mann" ;
> Sent: Thursday, November 05, 2009 11:36 PM
> Subject: Re: [PHP] Should I care about these errors?
>
>
>> At 6:02 PM +1000 11/5/09, Angus Mann wrote:
>>>but I guess my question is "Should I bother?"
>>
>> Yes.
>>
>> Learn to write error free code.
>>
>> Cheers,
>>
>> tedd
>>
>> --
>> -------
>> http://sperling.com http://ancientstones.com http://earthstones.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Should I care about these errors?
am 05.11.2009 15:45:33 von M.Ford
> -----Original Message-----
> From: S=E1ndor Tam=E1s (HostWare Kft.) [mailto:sandortamas@hostware.hu]
> Sent: 05 November 2009 14:00
> To: php-general@lists.php.net
> Subject: Re: [PHP] Should I care about these errors?
>=20
> I think, it is better to stick one way, doesn't matter really, which
> one.
> The difference between single and double quotes partly define which
> one
> you'd use, but other times it's better to use the same all time.
> Speaking about paranthesises, I'd rather use them, because it makes
> obvious
> that it is a function, and makes it easier to read your code.
But echo is not a function, it's a language construct, and the rules are sl=
ightly different. Leaving the parentheses out just emphasizes this -- but =
even with all this, it's still pretty much down to personal preference or h=
ouse style.
Cheers!
Mike
--=20
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
Leeds Metropolitan University, C507, Civic Quarter Campus,=20
Woodhouse Lane, LEEDS,=A0 LS1 3HE,=A0 United Kingdom=20
Email: m.ford@leedsmet.ac.uk=20
Tel: +44 113 812 4730
To view the terms under which this email is distributed, please go to http:=
//disclaimer.leedsmet.ac.uk/email.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Should I care about these errors?
am 05.11.2009 18:09:14 von TedD
At 11:50 PM +1000 11/5/09, Angus Mann wrote:
>OK...point taken.
>
>On a partly related matter, which of the following is "correct" or "Better" ?
>
>echo("Stuff to display...");
>or
>echo 'Stuff to display...';
>or
>echo "Stuff to display...";
>or
>echo('Stuff to display...');
I use:
echo('Stuff to display...');
First, it easy for me to read. Second, the processor doe not evaluate
the contents.
However,
echo 'Stuff to display...';
is probably the more "purest" route. You don't need the parenthesis.
If you have a variable in the mix, then use double quotes, such as:
echo("Stuff to display... $stuff");
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Should I care about these errors?
am 05.11.2009 18:26:34 von Robert Cummings
tedd wrote:
> At 11:50 PM +1000 11/5/09, Angus Mann wrote:
>> OK...point taken.
>>
>> On a partly related matter, which of the following is "correct" or "Better" ?
>>
>> echo("Stuff to display...");
>> or
>> echo 'Stuff to display...';
>> or
>> echo "Stuff to display...";
>> or
>> echo('Stuff to display...');
>
>
> I use:
>
> echo('Stuff to display...');
>
> First, it easy for me to read. Second, the processor doe not evaluate
> the contents.
>
> However,
>
> echo 'Stuff to display...';
>
> is probably the more "purest" route. You don't need the parenthesis.
>
> If you have a variable in the mix, then use double quotes, such as:
>
> echo("Stuff to display... $stuff");
>
This is really a personal preference. The same issue arises with the use
of require, require_once, include, and include_once. None of these are
functions (just like echo) and so they do not need the parenthesis. That
said... for eacho I prefer to leave the parenthesis off since it makes
formatting of text more convenient. However for require, include, etc...
I usually add parenthesis so that it looks like a function :)
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php