0

I'm bit confused about the meaning of this line:

$show_title = Ninja_Forms()->form( $form_id )->get_setting( 'show_title' );

Is -> available in PHP, or it used only within WordPress.

1
  • You should learn OOP programming. its a vary basic thing of OOP. Nov 27, 2015 at 10:53

1 Answer 1

2

NO -> is not wordpress specific, it is object operator in php.

When you want to call a method of an instance then you call the method with ->

Class SomeClass{

  function example(){
   return 'This is an example function'
  }

}
$obj = new SomeClass();
$obj->example(); // we are calling example function with -> operator

Additional Info: there is one more operator :: which is used to call for static methods of a class.

5
  • Also show an example the process of accessing this $show_title = Ninja_Forms()->form( $form_id )->get_setting( 'show_title' );
    – Menon Jats
    Nov 27, 2015 at 11:13
  • @JayaJeeth This is oops concept. Try it. for a help. let me give a little info on this you have asekd.
    – WPTC-Troop
    Nov 27, 2015 at 11:25
  • Ninja_Forms()->form( $form_id )->get_setting( 'show_title' ); Ninja_Forms() is a function which returns an object instance. so calling an method of it is form($form_id) and now this too returns an object instance. finally calling the method get_setting('show_title');
    – WPTC-Troop
    Nov 27, 2015 at 11:27
  • Nice. can you write a small program using this above for better understanding.
    – Menon Jats
    Nov 27, 2015 at 11:48
  • @JayaJeeth try the PHP documentation on object orientation and this tutorial from Code Academy
    – Burgi
    Nov 27, 2015 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.