Skip to content

Instantly share code, notes, and snippets.

@bitkorn
Last active February 13, 2018 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitkorn/ec7b45f0bbe03b74c9c3f12b61dfe425 to your computer and use it in GitHub Desktop.
Save bitkorn/ec7b45f0bbe03b74c9c3f12b61dfe425 to your computer and use it in GitHub Desktop.
only functions are separated with multiple namespaces in a file
<?php
namespace A {
$closure = function () {
echo __NAMESPACE__;
};
}
namespace B {
$closure = function () {
echo __NAMESPACE__;
};
$var = 'foo';
function foo()
{
return 'foofunc()';
}
}
namespace C {
use function B\foo;
$closure();
echo '<br>';
echo $var;
echo '<br>';
echo foo(); // only this require a use statement
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment