vendredi 9 août 2019

How to call two functions in one class in PHP OOP?

Please i need to create a functions and call them in one line using -> between them I have this code but it doesn't run

<?php 
class A {
    public $a2; 
    public $b2; 

    public function mohamed($a){
        $this->a2 =  $a;
        return $this ; 
    }
    public function test($b){
        $this->b2 =  $b;
        return $this ; 
    }
}
$class = new A();
echo $class->mohamed('name')->test('mohamed');;
?>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire