Strict Standards?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Strict Standards?

Post by Benjamin »

What are these new "Strict Standards" and why are they breaking all kinds of code?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you mean E_STRICT?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

I am using the newest version of phpMyAdmin on a linux pc running php version 5.0.4 and I keep getting errors such as:
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /mnt/storage/server/www/html/complete/database/libraries/storage_engines.lib.php on line 108
This is the second application that doesn't want to work very well under this version of php.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

PHP 5 introduced access restrictions to class variables. The keyword "var" doesn't exist in strict (meaning strict compliance mode). "var" is from PHP 4. Most scripts you will find in the wild right now are still written for PHP 4 in mind. They can not be completely compliant with 5 while maintaining PHP 4 support without different codebases for their objects, among other variances.

Since the code was written for 4, switching all the instances of "var" in that context to "public" will fix it, generally.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

agtlewis wrote:I am using the newest version of phpMyAdmin on a linux pc running php version 5.0.4 and I keep getting errors such as:
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /mnt/storage/server/www/html/complete/database/libraries/storage_engines.lib.php on line 108
This is the second application that doesn't want to work very well under this version of php.
Keep in mind that the PHP group realized just how harsh of a switch this was, and in PHP6, it will not give that notice.

It is an E_STRICT notice, not an error or warning.
feyd wrote:Since the code was written for 4, switching all the instances of "var" in that context to "public" will fix it, generally
Keep in mind that public/private don't work in php4, so switching it 'fixes' it for php5, but makes the script not run on php4.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

The easiest way, then, if you still want to enforce good coding practices, is set error_reporting to E_ALL (not E_STRICT)
Post Reply