Namespaces in non name-spaced class

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Markto
Forum Newbie
Posts: 22
Joined: Thu Nov 17, 2011 1:13 pm

Namespaces in non name-spaced class

Post by Markto »

Can you import a namespace into a class that doesn't have a name space?

I tried it by using "use (NAMESPACE)" in a class without a namespace but by IDE said this wasn't valid. I tried it anyway, but got an error.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Namespaces in non name-spaced class

Post by Celauran »

What did the error say? Maybe post some of the relevant code?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Namespaces in non name-spaced class

Post by requinix »

Literally in a class? As in

Code: Select all

<?php
namespace Languages;

class Greenlandic
{
    use Languages\Danish;

    ...
}
?>
Because I copied that code from the "Illegal importing rule" example in the documentation.
Post Reply