Answers for "constructor and destructor in php"

PHP
1

constructor and destructor in php

<?php
/*
    By defualt constructor call at the beginning and by defualt destructor call at the end.
    constructor and  destructor call automatic when object is called
*/
    class Birds
    {
        function __construct() 
        {
            echo "Start<br>";
        }
        function fun1() 
        {
            echo "this is function<br>";
        }
        function __destruct() 
        {
            echo "End";
        }
    }
    $parrot = new Birds();
    $parrot->fun1();
?>
Posted by: Guest on October-05-2021

Browse Popular Code Answers by Language