Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

relearning PHP, how has it changed?

Tags:

ajax

php

mysql

I'm planning on creating a small web app using PHP. The last time I used PHP was sometime around 2002/2003 where the code tended to be a horrid mash of PHP/HTML and Javascript shoved in a single file. I think I might have even been using PHP3...

I now want to relearn and want to know what's changed and what helper libraries and tooklits exist that might save me from unknowingly reinventing things.

E.g is there a "standard" MySQL library, or do we still use the basic PHP functions (as a side question, do stored procedures work in MySQL yet?)? What do I need to know in order to make a "modern" website that doesn't rely on whole page HTML form posts to send data back to the server, etc.

like image 430
Piku Avatar asked Nov 10 '10 10:11

Piku


1 Answers

Welcome back. PHP has gotten better!

If you can, start using 5.3 from the start; be aware though that many web hosts don't support it yet (if that is an issue). If confronted with PHP 4, run away screaming: It is no longer fit for production use.

  • The major development is finally proper OOP in PHP 5. Getting familiar with that is the only really mandatory thing in my eyes.

  • Several popular frameworks have evolved that do a lot of low-level work for you. The Zend Framework is a very high-quality code base to work with and my personal favourite because it's also usable as a component library that doesn't force its design principles upon you; there are others. (Here is a comparison site).

  • PDO is definitely the low-level database class de jour. It has parametrized queries preventing SQL injection and supports a number of databases.

  • The MVC design pattern is a very popular design pattern for building dynamic web sites and applications, and is embedded as a design philosophy into most PHP frameworks.

  • Class Autoloading is a great new PHP 5 feature.

  • A relatively little-noticed new development is the Standard PHP Library that brings clean, OOP solutions to everyday PHP problems. For example the DirectoryIterator that allows for easy recursive walking through directories; the ArrayObject provides an OOP interface to many (but not all) core array functions.

  • The DateTime class will replace the old UNIX timestamps over time. It provides improved functionality, and can work with dates beyond the 32 bit timestamp's 1970-2038 range.

This is some of the stuff under the hood. There are important client-side developments you want to be at least aware of; namely Ajax to fetch server-side data without reloading the page, and using a JavaScript Framework like jQuery to deal with the details. CSS you will already be familiar with.

like image 84
Pekka Avatar answered Sep 21 '22 04:09

Pekka