Thursday, November 17, 2005

Php Crib Sheet

Just in a case I lose yet another bit of paper.

Model:-

  • User requests a page with a URL
  • If that request was sent by a form, variable data may be sent to the server along with the request.
  • Web server receives request for object located at the URL
  • If that object (e.g. index.php) is a php file, the php code segment gets executed and replaced with the result of the code
  • Server sends the new, freshhly available file to the browser

Things to check:-

  • Am I accessing the right URL?
  • Did I upload the lastest version to the live server?
  • Did I type everything correctly? (Everything is case sensitive, spaces are not allowed in URLs or filenames)
  • Do I have a code segment starting with
  • Does every line of php code end with a semi-colon (;)?
  • Do I have an ending bracket for every open bracket? ( "(", "[", "{")
  • Did I mistakenly type letter '1' instead of digit '1'?
  • Did I mistakenly type letter 'o' instead of digit '0'?
  • Did I remember that variable names start with '$'?
  • Did I remember that arrays start with index 0, not index 1?
  • If I get a message saying "error parsing line 101", did I check that line 100 is correct? Does it end with a semi-colon (;)?
  • Did I try debugging by using "echo $variable" in critical places in the php code?

No comments: