Php Namespace Class

[Solved] Php Namespace Class | Php - Code Explorer | yomemimo.com
Question : php namespace class

Answered by : israel-j

<?php
namespace m\name; // see "Defining Namespaces" section
class MyClass {}
function myfunction() {}
const MYCONST = 1;
$a = new MyClass;
$c = new \my\name\MyClass; // see "Global Space" section
$a = strlen('hi'); // see "Using namespaces: fallback to global
                   // function/constant" section
$d = namespace\MYCONST; // see "namespace operator and __NAMESPACE__
                        // constant" section
$d = __NAMESPACE__ . '\MYCONST';
echo constant($d); // see "Namespaces and dynamic language features" section
?>

Source : https://www.php.net/manual/en/language.namespaces.rationale.php | Last Update : Tue, 11 May 21

Answers related to php namespace class

Code Explorer Popular Question For Php