PHP new Keyword

PHP or Keyword
PHP namespace Keyword

In this article, you will learn how to create a new object in PHP. The new keyword in PHP is used to create an object from a class.

examples of the NEW function

Example 1. In this example, we create an object and output the value of one of its properties.

<?php
class MyClass {
  public $name = "John";
}

$obj = new MyClass();
echo "The name is " . $obj->name;
?>
PHP or Keyword
PHP namespace Keyword

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top