PHP class Keyword

❮ PHP Keywords

Example

Declare a class:

<?php
class MyClass {
  public $number = 5;
}

$obj = new MyClass();
echo $obj->number;
?>
Try it Yourself »

Definition and Usage

The class keyword is used to create classes.


Related Pages

Read more about classes in our PHP Classes and Objects Tutorial.


❮ PHP Keywords
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.