php class constants
snippet in php

create a constant in php

user5339


<?php

 define("GREETING", "Welcome to W3Schools.com!");
echo GREETING;
?>
 

php class constants

user2649


    <?php
class Goodbye {
  const LEAVING_MESSAGE = "Thank you for visiting W3Schools.com!";
  
    public function byebye() {
    echo self::LEAVING_MESSAGE;
  
    }
}

$goodbye = new Goodbye();
$goodbye->byebye();
?>