Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php: "notice" warnings on different machine

Tags:

php

notice

i've set up all my php stuff on a new machine and i'm getting really lots of notices warnings.

my code is working properly without errors on my old machine.

eg. the following line (which should get a recordset value) will cause a notice: $ID = $rs[id];

the reason is the missing quotes for the id fields, but also things like calling $_GET on a non-existing value will cause notices.

anyone knows what's the reason for this? i'd love keeping the "simple" way of coding like on my old machine without having to hassle with quotes on recordsets or tons of isset() - any ideas?

thanks

like image 775
Fuxi Avatar asked May 05 '11 19:05

Fuxi


People also ask

How do I stop display warnings in PHP?

in Core Php to hide warning message set error_reporting(0) at top of common include file or individual file.

How do I stop PHP error messages?

Remember, the PHP ini configuration has an error_reporting directive that will be set by this function during runtime. error_reporting(0); To remove all errors, warnings, parse messages, and notices, the parameter that should be passed to the error_reporting function is zero.

How does PHP handle notice error?

Error Logging By default, PHP sends an error log to the server's logging system or a file, depending on how the error_log configuration is set in the php. ini file. By using the error_log() function you can send error logs to a specified file or a remote destination.

Is PHP notice an error?

Notice ErrorNotice errors are minor errors. They are similar to warning errors, as they also don't stop code execution. Often, the system is uncertain whether it's an actual error or regular code. Notice errors usually occur if the script needs access to an undefined variable.


1 Answers

The PHP installation in the new machine has a more robust configuration that shows notices, and not only errors. That's good. I would never write or accept in my server a PHP script that fires some notice.

This kind of "lazy" coding (forgive me, I want to help you!) brings to future issues (code is hard to read and to debug) and, indirectly, security concerns ("lazy" code is often flawed). Fix everything that fires up a notice. :)

And, if you can, learn some more advanced PHP: go for object-oriented programming, encapsulation, information hiding, etc... This is how things are done nowadays and they work better than before. Old PHP scripts, built around notice suppression and register_globals, were somewhat dump.

like image 180
gd1 Avatar answered Oct 11 '22 23:10

gd1