Re: Simple class declaration returns error
What version of PHP are you using?
I suspect something less then 5.0 which means the public/private
declarations are not supported...
(So remove 'public' and see if it works)
-Brad
Dave M G wrote:
> PHP List,
>
> I am in the preliminary stages of designing my first object oriented
> PHP based web site.
>
> I've created file called "article.class" and included it in my
> index.php file. I put in a very simple echo statement, just as a place
> marker before I put in the real code, and just to make sure that the
> index.php file is successfully including the class.
>
> So far, it just looks like this (including line numbers):
>
> 4. class article{
> 5. public function edit(){
> 6. echo "test";
> 7. }
> 8. }
>
> However, when I view my index.php, it says:
>
> Parse error: syntax error, unexpected T_STRING, expecting
> T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /web/article.class on
> line 5
>
> Of course I consulted the PHP manual to make sure that I had the class
> syntax correct, and it seems that I've followed the basic structure as
> described there.
>
> Where have I gone wrong?
>
> Thank you for any advice.
>
> --
>
> Dave M G
>