View Single Post
Old 08-28-2012, 02:18 PM  
isteve
Confirmed User
 
isteve's Avatar
 
Industry Role:
Join Date: Jun 2012
Location: Saint-Jean-sur-Richelieu (near Montreal)
Posts: 191
Quote:
Originally Posted by edgeprod View Post
Would you suggest an alternate way of doing that than the current way?

Code:
   public $returnText = 'Hello World!';  // Stores the string to return
Is there something inherently wrong with the way I'm doing it? I'd love to learn, if so.
You should use a constructor to initialize class members:

PHP Code:
class Hello {

    private 
$returnText;
    public function 
__construct() {
        
$this->returnText "Hello World!";
    }


Last edited by isteve; 08-28-2012 at 02:23 PM..
isteve is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote