Re: OOP Newbie - why does this not work?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux