I looked at this code here about creating classes
<?php
class Item {
protected $name, $price, $qty, $total;
public function __construct($iName, $iPrice, $iQty) {
$this->name = $iName;
$this->price = $iPrice;
$this->qty = $iQty;
$this->calculate();
}
protected function calculate() {
$this->price = number_format($this->price, 2);
$this->total = number_format(($this->price * $this->qty), 2);
}
public function __toString() {
return "You ordered ($this->qty) '$this->name'" . ($this->qty == 1 ? "" : "s") .
" at \$$this->price, for a total of: \$$this->total.";
}
}
echo (new Item("Widget 22", 4.90, 2));
?>
http://php.net/manual/en/language.oop5.php
What i would like to know is that in this example, there is the function "__tostring()" which prints out the message to screen.
However, in the MVC architecture, it seems to be that
Class - is the model with only functions that return a calculation
logic - is in the Controller file which calls classes and controls logic
display - is in the view file which displays information to teh user.
So, where would such text really be stored to create a neat separation between model, logic and view?
1 - Simply, where is the best place to put text that will be displayed to the user?
Is it in the logic file or view file?
2 - The second question is that if the text to display is to be made editable by the administrator, how does one go about creating and linking a file that contains all messages so that instead of having "You ordered .....", say a variable can be used so that the adminitrator can set that text to whatever preference is desired, say "You purchased...." and possibly when language support is used, the language file enabled can contain the variables with the matching language.