Reply to Re: [PHP] OOP Newbie - why does this not work?

Your name:

Reply:


Posted by Jochem Maas on 10/21/05 11:09

Bob,

'wrapping' you class definition within HTML like you have done is
not only weird but down right ugly. I recommend sticking each class
you write in a seperate file and using include_once() or require_once()
before you output anything to the browser. basically try to
seperate you code into 'stages' (for want of a better word) e.g.:

1. setup an environment (includes loading classes)
2. process the request
3. redirect or output a page

Bob Hartung wrote:
> Hi all,

....

>
> </head>
> <body>
> <br>
> <P>This is outside the php code block</P>
> <br>
> <?php
> echo "Start defining the class here: <BR>" ;
> /* class Test
> {
>
> function __constructor()
> {
> var $saying ;

'var' doesn't belong here. it belongs directly in the body of class def.

> $saying = "Im in the Test Class" ;
> }
>
> function get()
> {
> return $saying ;


there is a missing '}' here.
also you should be returning and setting $this->saying


>
> }
>
> var $liveclass ;

drop the 'var' - it's only for php4 and then only for
defining the properties of classes/objects:

class Test {
var $myProperty;
}

> $liveclass = new Test ;
> echo $liveclass->get() ;
> echo "<BR>" ;
> echo "This is in the php code block" ;
> */
> ?>
>
> </body>
> </html>
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация