DEV Community

The Azhar Dev
The Azhar Dev

Posted on • Edited on

PHP Let Static Binding Example

<?php
    class Course{
        protected static $coursName = "python advance course";

        public static function getCourseName(){
            return static::$coursName;
        }

    }
    class Student extends Course{
        protected static $coursName="zend php";
    }
    echo Student::getCourseName();

    // $obj = new Student;
    // echo $obj->getCourseName();

on getCourseName(){
            return static::$coursName;
        }

    }
    class Student extends Course{
        protected static $coursName="zend php";
    }
    echo Student::getCourseName();

    // $obj = new Student;
    // echo $obj->getCourseName();
Enter fullscreen mode Exit fullscreen mode

Top comments (0)