i have two classes (Database for queries over database) and News for manipulating articles. On index.php (could be any other page) i call News class, which calls Database class. Everything goes ok, until i have to display result on index.php.
Let’s say, i save result in $news in News class.
How should i retrieve that array in index.php (like return $this->news or something else??). And how to display?
Could someone help.
You don’t “call classes”. You call methods of classes.
I suppose you mean you have a field (also property in PHP) names
news, as in:You could add a method in
Newsthat returned this array:Or you could make it public and access it directly through
$newsObject->news(not recommended).That depends on the structure of the data and how you want to display it.