Training, Open Source computer languages

This is page http://www.wellho.net/forum/Writing-PHP/use-strict.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
use strict

Posted by John_Moylan (John_Moylan), 17 July 2002
Well 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?

jfp


Posted by admin (Graham Ellis), 18 July 2002
Both 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

http://www.php.net/manual/en/function.error-reporting.php

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);

Graham



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho