note 117187 deleted from language.namespaces.definitionmultiple by cmb
| From: | cmb@php.net | Date: | Mon, 19 Oct 2020 15:36:01 +0000 |
| Subject: | note 117187 deleted from language.namespaces.definitionmultiple by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215617@lists.php.net to get a copy of this message | ||
Note Submitter: Luis Pessoa
----
Be careful with include combined to namespaces:
file b.php
<?php
const WHERE_I_AM = 'I am in B';
function i_am_in() {
\A\cr_echo(WHERE_I_AM);
}
?>
file c.php
<?php
namespace C {
const WHERE_I_AM = 'I am in C';
function i_am_in() {
\A\cr_echo(WHERE_I_AM);
}
}
?>
main file
<?php
namespace A {
const CR = "\r\n";
const WHERE_I_AM = 'I am in A';
function cr_echo($msg) {
echo $msg . CR;
}
function i_am_in() {
cr_echo(WHERE_I_AM);
}
}
namespace B {
require 'b.php';
}
namespace {
require 'c.php';
\A\i_am_in(); //ok
\B\i_am_in(); // fatal-error
\C\i_am_in(); //ok
}
?>