I've no problems testing my application in localhost.
When I tried to get my webapp working in a shared host I always get the error exception in the title.
My code:
<?php
use Yii;
....
?>
html code
I know that this is redundant, but I like to see what I'm _using_ in the file.
The framework is using this too, in some files.
But never in a php file with html code (e.g. yii basic application).
There's a specific reason for this? (Or why in the world I get this error (which breaks my app) in the server but not in localhost).
use Yii; is necessary when you want to use the name Yii inside of a namespace, this does not make sense when used in a file that has no namespace.
Thanks for the fast reply!
But this _uses_ are necessary because you want to use them.
If not, why just Yii doesn't make sense in a view file (no namespace)?
~ Do you know why I don't get this error in my localhost? (php config?)
Yii is in the global namespace. The use keyword is used to import(well, alias) a class into the current namespace. PHP will warn you (or fatal with certain names) if you try to import a global class into the global namespace for example in a view context (which doesn't make sense):
Example:
http://3v4l.org/K0D61#v530
~ Do you know why I don't get this error in my localhost? (php config?)
you may have set error_reporting to a lower level, it is recommended to show all errors to write clean code and do not get surprised when something behaves weird just because you did not see the warning.
Really, really thank for both of you!
@suralc nice example, I get it now.
@cebe I added all possible errors now.
Most helpful comment
Yiiis in the global namespace. Theusekeyword is used to import(well, alias) a class into the current namespace. PHP will warn you (or fatal with certain names) if you try to import a global class into the global namespace for example in a view context (which doesn't make sense):Example:
http://3v4l.org/K0D61#v530