| 
 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> 
>
 
  
Navigation:
[Reply to this message] 
 |