-
January 5th, 2009, 12:26 PM
#1
PHP Namespace Error
I keep getting an error. Here is some code.
Code:
<?php // PSystem.php
namespace PSystem;
?>
Yeah, that's all.
Code:
<?php // tester.php
include 'PSystem.php';
echo "Works";
?>
I keep getting this error.
Code:
PHP Parse error: syntax error, unexpected T_STRING in C:\\Server\\Main\\Includes\\PSystem.php on line 2
Is this how you are supposed to be loading namespaces, or is this just some weird error?
-
January 5th, 2009, 01:47 PM
#2
Re: PHP Namespace Error
Try this for PSystem.php
PHP Code:
<?php
namespace PSystem {
const a = 1;
}
?>
Help from me is always guaranteed!*
VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.
*Guarantee may not be honoured.
-
January 5th, 2009, 03:07 PM
#3
Re: PHP Namespace Error
Are you sure there isn't an accidental white-space before the PHP declaration? Remember that namespaces must be declared before output within a script.
Also...Have you tried it with actual content in the namespace?
@javajawa You are declaring your namespace as you would a class.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
January 5th, 2009, 05:59 PM
#4
Re: PHP Namespace Error
Newer versions of PHP allow for that form of namespace declaration. It's useful for keeping track of where you want namespaces to end (so you can remember to re-open the global namespace, something I always forget otherwise) PHP Manual Entry
Help from me is always guaranteed!*
VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.
*Guarantee may not be honoured.
-
January 5th, 2009, 06:52 PM
#5
Re: PHP Namespace Error
Ah, yes peej. I can write
Code:
namespace [name]
{
}
But, what about...
Code:
namespace [name] \ [subspace] \ [subspace]
{
}
I don't think that will work, hmm well I gotta try.
-
January 5th, 2009, 08:45 PM
#6
Re: PHP Namespace Error
You learn something new every day! I haven't worked with namespaces much. Useful little thing to know.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
January 13th, 2009, 05:49 AM
#7
Re: PHP Namespace Error
Nope, nothing seems to work.
Does that mean I can't use namespaces, at all? lame.
How would I display my php info? I know there was a function and it would list everything in a complete page.
Oh, wait a second.
It says in phpinfo().
Powered By PHP/5.2.5.
Would that be of any significance?
Last edited by code?; January 13th, 2009 at 06:25 AM.
-
January 13th, 2009, 03:28 PM
#8
Re: PHP Namespace Error
Namespaces are available in PHP as of PHP 5.3.0.
[Source: PHP Manual]
Help from me is always guaranteed!*
VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.
*Guarantee may not be honoured.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|