1

how i can create class with this call syntax

oop->open(file)->select_row(3)->update('this is row3')->save();

an other question if i have class and i wont make plugin for it , every plugin in each php file separate... my Ex.

class Foo { 
    function foo1() { 
        print 'foo foo';
    }
}

function plugin_foo(){
   print 'this from plugin_foo';
}

$foo = new Foo; 
print $foo->foo1()->plugin_foo()

oop->open(file)->select_row(3)->update('this is row3')->save();

an other question if i have class and i wont make plugin for it , every plugin in each php file separate... my Ex.

class Foo { 
    function foo1() { 
        print 'foo foo';
    }
}

function plugin_foo(){
   print 'this from plugin_foo';
}

$foo = new Foo; 
print $foo->foo1()->plugin_foo()

2 Answers2

1

It is called method chaining. By returning the instance of the itself, it can chain calls.

class Foobar
{ 
   function foo()
   {
      echo 'hi';

      return $this;
   }
}
Rasclatt
  • 12,498
  • 3
  • 25
  • 33
John Cartwright
  • 5,109
  • 22
  • 25
0

You need to return the object of that same class in every methods.

Dioni Butter
  • 169
  • 7