Class

Estimated reading time: 1 minute

class

class Me {
  function info(){
    echo "this is user info";
  }
}
$t = new Me();
$t->info();
# this is user info

properties

  • variables are called properties which live in class

static

  • no need to declare of class objects (new)
  • scope :: operator
class Me {
  static function info(){
    echo "this is user info\n";
  }
}
Me::info();
# this is user info

➲(laravel ) : static live in facades folder

abstract class

abstract class me{} → extends me

~ resources

interface

interface me{} → implements me

➲(laravel ) : intreface live in contract folder

trait

trait is a process that reuse methods . if you are Vue developer or SASS(css), you know about mixins . trait as like mixins

trait me{} → use me

constructor

class A {

 function __construct() {
  echo "constructor automaticaly return when class call";
 }
}

$obj= new A();
 # constructor automaticaly return when class call
?>

~ resource

php