Multiple PHP Objects

Video loading...

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 object-oriented or OO stuff gets a really
  • 0:09
    fun once we have multiple objects.
  • 0:11
    After all, it takes at least two ships to start a battle.
  • 0:15
    But first, let's summarize all of this printing stuff
  • 0:18
    into a normal, traditional flat function called printShipSummary.
  • 0:24
    It'll take in a ship object as an argument, which I'll call someShip.
  • 0:31
    Now copy all the echo stuff into the function.
  • 0:35
    The argument to the function could be called anything.
  • 0:38
    Since I chose to call it someShip, all of the myShip variables