PHP Class Method Arguments

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:05
    Our two methods are simple.
  • 0:08
    So now let's add something useful.
  • 0:10
    We'll be printing out the details of our ships all over the place.
  • 0:14
    So I need to wait to see the weapon power, the strength,
  • 0:17
    and the Jedi factor all at once.
  • 0:20
    Like a little summary.
  • 0:22
    One handy way to do this is with a new method
  • 0:25
    that creates that summary string and returns it to us.
  • 0:29
    Make a new function, getNameAndSpecs.
  • 0:37
    Let's use the nice sprintf function with percent

PHP Class Method Arguments


In this lesson, you'll get more practice working with methods. Along with adding some functionality to a method using PHP's sprintf() function to format a string, you'll use the $this pseudo-variable, and learn how to add and use arguments with methods.

Log in or sign up to download companion files.
Additional resources: