Rotate your phone or change to desktop for better experience

Rotate your phone or change to desktop for better experience

Develop a PHP program to demonstrate constructors and destructors.

 

<?php

class rectangle

{ var $height;

 var $width;

 function __construct($arg1, $arg2)

 {

 $this->height=$arg1;

 $this->width=$arg2; }

 function show()

 {

 echo "Height=$this->height Width=$this->width";

 }

 function __destruct()

 {

 echo "<br> Object is Destroyed";

 } }

$obj=new rectangle(10,20);

$obj->show();

?>

Post a Comment

0 Comments