StepsEasy
PHP Abstract Classes - Example
Run
Reset
Destroy & Close
← Back to lesson
Code Editor
php
<?php class User { private string $name; private string $email; public function __construct(string $name, string $email) { $this->name = $name; $this->email = $email; } public function getName(): string { return $this->name; } public function greet(): string { return "Hello, I'm {$this->name}!"; } } $user = new User('Alice', 'alice@example.com'); echo $user->greet(); // Hello, I'm Alice! ?>
Result
Click "Run" to execute the code...
Loading runtime...
Ready
PHP | In-Browser Execution