okay, I had solve it myself. It's due to my fault that I write "$this->$html" to access class members, but "$this->html" is correct. Thanks all guys. Thank you for your paying attention to this.to surfchen(冲浪) : OOD is a solutions and methods set to help we to build a system. Every languages has its spec to implements those. In this issue, it's a solecism that I made. In the case of I write a new class to replace it, It will still not work. But thanks you all same.
There is the answer: The variable is named $cart->items, not $cart->$items, that is, a variable name in PHP has only a single dollar sign. <?php // correct, single $ $cart->items = array("10" => 1); // invalid, because $cart->$items becomes $cart->"" $cart->$items = array("10" => 1);// correct, but may or may not be what was intended: // $cart->$myvar becomes $cart->items $myvar = 'items'; $cart->$myvar = array("10" => 1); ?>
There is the Cart class class Cart { var $todays_date; var $name; var $owner; var $items = array("VCR", "TV"); function Cart() { $this->todays_date = date("Y-m-d"); $this->name = $GLOBALS['firstname']; /* etc. . . */ } }
是__construct,两横的~~
class Action{
function doAction(){
print("test");
}
}
class Temp{
private $action;
private $html;
public function _construct(){
}
function getAction(){
return $this->$action;
}
function getHtml(){
return $this->$html;
} function setAction($_action){
$this->$action = $_action;
}
function setHtml($_html){
$this->$html = $_html;
}
}class Config{ function getName($name){
$Temp = new Temp();
$action = new Action();
$html = 2;
$screen->setAction($action);
$screen->setTemplate($html);
return $temp;
}
}
class A{
function execute(){
$config = new Config();
$aa = "random";
$tt = $config->getName($aa);
print($tt->getAction());
}
}
function __construct()
$screen在哪里实例化的?
class Config{ function getName($name){
$Temp = new Temp();
$action = new Action();
$html = 2;
$Temp->setAction($action);
$Temp->setTemplate($html);
return $temp;
}
}
class Config{ function getName($name){
$Temp = new Temp();
$action = new Action();
$html = 2;
$Temp->setAction($action);
$Temp->setHtml($html);
return $temp;
}
}
Thanks all guys. Thank you for your paying attention to this.to surfchen(冲浪) :
OOD is a solutions and methods set to help we to build a system. Every languages has its spec to implements those. In this issue, it's a solecism that I made. In the case of I write a new class to replace it, It will still not work. But thanks you all same.
The variable is named $cart->items, not $cart->$items, that is, a variable name in PHP has only a single dollar sign. <?php
// correct, single $
$cart->items = array("10" => 1); // invalid, because $cart->$items becomes $cart->""
$cart->$items = array("10" => 1);// correct, but may or may not be what was intended:
// $cart->$myvar becomes $cart->items
$myvar = 'items';
$cart->$myvar = array("10" => 1);
?>
class Cart {
var $todays_date;
var $name;
var $owner;
var $items = array("VCR", "TV"); function Cart() {
$this->todays_date = date("Y-m-d");
$this->name = $GLOBALS['firstname'];
/* etc. . . */
}
}