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;
?>
Try it Yourself »
The new
keyword is used to create an object from a class.
Learn more about classes and objects in our PHP OOP - Classes and Objects Tutorial.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!