Student M&Cs in PHP

The same kinds of programming misconceptions that are found in Scratch, Python, and Javascript may occur in PHP.  Students may have fundamental misunderstanding related to variables, loops, etc.  In addition, there are common mistakes that students often make when coding in PHP.  These include:

  • Parse errors. Most syntax errors in PHP are identified as parse errors. These can occur, as with Javascript, if the student fails to properly close an open quote mark, parenthesis, or curly bracket, or has missing punctuation, such as a forgotten semi-colon at the end of a statement.
  • Unexpected T-something. This error, like a parse error, often results from a missing punctuation mark prior to the point of the error. When errors occur in PHP, students should look before the point of the error for inadvertent omissions.
  • Omitted $ in variable names. PHP requires a $ to identify variables. If a student accidentally forgets to include the $ in referencing a variable, an error will result.
  • Improper conditional expressions. Like Javascript, in PHP a conditional statement must use the proper comparison operation, e.g., if (var1 == var2) but NOT (if var1 = var2).
  • Blank page. If nothing appears when testing a PHP script, most likely there is an error but error information is probably not being reported. PHP error reporting should be turned on during testing and debugging. Error reporting can be turned on by adding the following line of code at the top of a script:  <?php ini_set(‘display_errors’, ‘1’); ?>