Advertisement
Yousuf1791

destructor-function

May 15th, 2023
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.27 KB | None | 0 0
  1. <?php
  2.  
  3. class name{
  4.     public $name;
  5.  
  6.     function __construct($n = "No name"){
  7.         $this->name = $n;
  8.     }
  9.  
  10.     function __destruct(){
  11.         echo "My name is $this->name";
  12.     }
  13.  
  14.     function test(){
  15.         echo "Hello World";
  16.     }
  17. }
  18.  
  19. $obj = new name("Yousuf");
  20.  
  21. // $obj->test();
  22.  
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement