Posted by John_Moylan (John_Moylan), 17 July 2002Well after using PHP for the past month my biggest gripe is the lack of 'use strict'.
This pragma has been a godsend in Perl, surely it's got to come soon to PHP.
Or am I the only one who thinks this?
Posted by admin (Graham Ellis), 18 July 2002Both Perl and PHP have "grown up" from languages in which programmers wrote relativly short utility scripts into languages in which major applications are written. This forum is a good example - it happens to be written in Perl (yes, I know I'm posting on the PHP board!), but that's not the origins. Recall that PHP was originally "Personal Home Pages", and Perl is the "Practical Extraction and reporting language". Neither of these imply big applications.
When writing a shorter piece of code, having to declare variables adds code which isn't really necessary. It takes time to type in all those "int" or "float", "my" or "our" words and ensure that they're all present, and for what real gain? As your application gets longer, so variable declaration does have a point - it ensures that you don't have a "typo" somewhere in your code that is hard to find during testing and it helps in the "selfdocumentation" of something that's going to take more reading / understanding than a little utility.
PHP does not (as far as I know) have an equivalent of "use strict". You can use the error_reporting function to help you catch variables that you have not initialised in your code; see the online manual at
Here's an example of it in use:
// Reporting E_NOTICE to report uninitialized
// variables or catch variable name misspellings ...
error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
Comment by Rutishauser (published 2010-07-15)
I agree with John. The bulk of time is spent on design and debugging, rather than on pressing keys on the keyboard. So, no matter what you are writing, a big complicated program or a couple of simple lines, strict typification is certainly of great help. [#3629]
You can Add a comment or ranking or edit your own comments
Average page ranking - 4.0
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho