note 117187 added to language.namespaces.definitionmultiple
| From: | LuisPessoa | Date: | Tue, 28 Apr 2015 17:30:11 +0000 |
| Subject: | note 117187 added to language.namespaces.definitionmultiple | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202391@lists.php.net to get a copy of this message | ||
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
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 200.142.0.4
----
Manual Page -- http://php.net/manual/en/language.namespaces.definitionmultiple.php
Edit -- https://master.php.net/note/edit/117187
Del: integrated -- https://master.php.net/note/delete/117187/integrated
Del: useless -- https://master.php.net/note/delete/117187/useless
Del: bad code -- https://master.php.net/note/delete/117187/bad+code
Del: spam -- https://master.php.net/note/delete/117187/spam
Del: non-english -- https://master.php.net/note/delete/117187/non-english
Del: in docs -- https://master.php.net/note/delete/117187/in+docs
Del: other reasons-- https://master.php.net/note/delete/117187
Reject -- https://master.php.net/note/reject/117187
Search -- https://master.php.net/manage/user-notes.php