note 126965 added to language.namespaces.nsconstants

From: Date: Wed, 30 Mar 2022 08:37:06 +0000
Subject: note 126965 added to language.namespaces.nsconstants
Groups: php.notes 
Request: Send a blank email to php-notes+get-217782@lists.php.net to get a copy of this message
Difference between __NAMESPACE__ and keyword 'namespace' that I find relevant is when invoking a class: <?php namespace MyApp; class App { static function app(){ echo 'hello app'; } } // this will work: $obj = new namespace\App::app(); // this will not work $obj = new __NAMESPACE__\App::app(); // however this will work: $obj = __NAMESPACE__ . '\App'; $obj::foo(); ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.135 (proxied: 2400:1a00:b020:4701:9168:df5c:1717:8eb2) ---- Manual Page -- https://php.net/manual/en/language.namespaces.nsconstants.php Edit -- https://main.php.net/note/edit/126965 Del: integrated -- https://main.php.net/note/delete/126965/integrated Del: useless -- https://main.php.net/note/delete/126965/useless Del: bad code -- https://main.php.net/note/delete/126965/bad+code Del: spam -- https://main.php.net/note/delete/126965/spam Del: non-english -- https://main.php.net/note/delete/126965/non-english Del: in docs -- https://main.php.net/note/delete/126965/in+docs Del: other reasons-- https://main.php.net/note/delete/126965 Reject -- https://main.php.net/note/reject/126965 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217782) next »