Namespaces จัดระเบียบโค้ด PHP และป้องกัน การชนกันของชื่อ (naming collisions) ระหว่างคลาส ฟังก์ชัน และค่าคงที่ ซึ่งจำเป็นเมื่อแอปพลิเคชันเติบโตขึ้นและใช้แพ็กเกจจากภายนอก มันทำงานเหมือนไดเรกทอรีสำหรับชื่อคลาส และทำงานร่วมกับ Composer autoloading (PSR-4)
ปัญหาที่ namespace แก้ไข
Without namespaces, two classes named `User` (yours and a library's) would COLLIDE
("cannot redeclare class"). Namespaces give each a unique fully-qualified name.
การประกาศและใช้ namespace
\;
{
}
