<?php

class One{
    public $name = "Sudhir Gour";
    
    public function showName(){
        echo "This is my Name : $this->name \n";
        echo "This access method doesn't work : " . self::$name;
    }
}


class Two{
    static public $name  = "Sudhir Gour";
    
    public function showName(){
        echo "This is my Name : " . self::$name . "\n";
        //echo "This is also my Name accessing it here doesn't work : $this->name \n"; // Warning : Accessing static property Two::$name
    }
}

// $one = new One();
// echo "Accessing name using class object : " . $one->name ."\n";
// $one->showName();

$two = new Two();
//echo "Accesssing static name using class object : " . $two->$name . "\n"; // Warning undefined variable name;
$two->showName();

echo "Accessing static name using class :: name : " . Two::$name . "\n";

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: