Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Definisi kelas
- class Person {
- public $name;
- }
- class Student extends Person {
- public $studentId;
- }
- // Pembuatan objek
- $person = new Person();
- $student = new Student();
- // Penggunaan operator instanceof
- $result1 = $person instanceof Person;
- $result2 = $student instanceof Person;
- $result3 = $student instanceof Student;
- echo $result1; // Output: 1 (true)
- echo $result2; // Output: 1 (true)
- echo $result3; // Output: 1 (true)
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement