Use PHP Objects

Video loading...

Transcript language code: 

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:03
    with Leanna Pelham
  • 0:05
    This play.php file is cute,
  • 0:08
    but it's not a real application.
  • 0:11
    We did make this nice Ship class, so let's use it.
  • 0:14
    It will clean up our code and give us more power.
  • 0:17
    Sounds good to me.
  • 0:19
    But first the Ship class lives inside play.php,
  • 0:23
    and this is just a garbage file we won't use anymore.
  • 0:26
    Usually a class will live all alone in its own file.
  • 0:30
    Create a lib directory and a file called Ship.php.