Friday, 5 March 2021

PHP 7 Namespace consants


Namespace with class constants 

<?php

namespace Information;

class A  {

    const ROOT_URL = 'test';

}


echo \Information\A::ROOT_URL;


// Result: test



Namespace with constants 

namespace Information;

const ROOT_URL = 'test';


echo \Information\ROOT_URL;


// Result: test


https://stackoverflow.com/questions/18247726/php-define-constants-inside-namespace-clarification


No comments:

Post a Comment