mercredi 26 mars 2014

Constructing Class Variables


Vote count:

0




I am trying to make my class variables in the 'global scope' of my web application so they can be used within other classes easily and throughout the web application when you call them. Here is my Articles Class for my web application.



class Articles {

// Defined variables that constructs an Article
private $id
private $title
private $summary
private $content
private $author

public function __construct($id, $title, $summary, $content, $author) {
// Constructs our Article by default
$this->id = $id;
$this->title = $title;
$this->summary = $summary;
$this->content = $content;
$this->author = $author;
}
}


And here is my init.php file



// Require the Articles and ArticlesHandler Class
require 'Articles/Articles.php';
require 'Articles/ArticlesHander.php';


If I needed to call the $title in the ArticlesHandler, does it have access to just using $title or do I need it call it using $this->title? Or is there a better method to do this?



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire