I've been looking over some of the newer features of PHP 5.3 and notice that they have updated the namespace documentation. I have been programming with the dev builds with this new system, and have been using the old method of the double colon (::) to refer to certain namespaces. I'm a little confused as to how they reworked it, and am wondering if anyone could explain to me how this new way is handled.
So I'm just wondering if this is correct... The old namespace system went from...
File 1:
File 2:
To...
File 2:
And to reference to sub namespaces, instead of using the double colon, I should just join them together; so for instance, instead of
I use
Because, in a sense this completely messes with what I think of as clean code.
Unless, I can completely ignore the new system, and use the double colon?
They also mentioned something about backslashes to seperate parent namespace from subnamespaces.
So could I use for example
File 2:
I know this post is a little crude and confusing, but please bear in mind that the new documentation completely baffled me (which is unusual since the little symbols like the double colon, or backslash (which they mentioned but did not use in any real code examples) help drastically in understanding what is what).
So I'm just wondering if this is correct... The old namespace system went from...
File 1:
Code:
<?php
namespace test_module;
class main
{
// Code...
}
?>
Code:
<?php
include ('file1.php');
$name = new test_module :: main ();
?>
File 2:
Code:
<?php
include ('file1.php');
$name = new test_modulemain ():
?>
Code:
namespace :: subnamespace
Code:
namespacesubnamespace
Unless, I can completely ignore the new system, and use the double colon?
They also mentioned something about backslashes to seperate parent namespace from subnamespaces.
So could I use for example
File 2:
Code:
<?php
include ('file1.php');
new test_module\main ();
?>
Comment