1 . class attribute => array
=>$this->a['a'];
class c
{
var $a = array('a'=>'aa','b'=>'ab');
var $b = 'c';
function show()
{
echo $this->a['a']; // -> 1st
echo $this->a['b']; // outputs 'ab'
$a = 'a';
$b = 'b';
echo $this->$a[$a]; // [] 1st, not what I expected
//Above first becomes $this->$a['a'] by looking at the function's local $a
//Next it becomes $this->a by again looking at the function's local $a, which references the class variable $a with no subscripts.
// In order to reference elements of the class variable $a,
// you want to use $this->a[$a]
echo $this->$a[$b]; // does NOT output 'ab'
// Same as above, but the first step $b becomes 'b'
$this_a =& $this->$a; // work-around
echo $this_a[$a]; // no question
echo $this_a[$b];
$a_arr = array('a'=>'b');
echo $this->$a_arr[$a]; // [] 1st => outputs 'c'
// This becomes $this->$a_arr['a'] which becomes $this->c,
// by referencing the local variables first.
}
}
$c = new c();
$c->show();
?>
2. array 0=>object
class test{
var $go =5;
var $go1 =15;
var $go2 =25;
}
class test2{
var $go =5;
var $go1 =15;
var $go2 =25;
}
$array = Array(new test,new test2);
Array ( [0] => test Object ( [go] => 5 [go1] => 15 [go2] => 25 ) [1] => test2 Object ( [go] => 5 [go1] => 15 [go2] => 25 ) )
Personal notes ~
2008年5月19日 星期一
訂閱:
文章 (Atom)
追蹤網誌清單
IT Info
Reference
標籤
- 代討論
- 防盜
- 常規表示式(regular expression)
- 進度
- 電子地圖
- 網站搬家程式
- Ajax Library
- Application of Perl
- C#
- CakePHP
- Coding Convention
- CSS
- Data injection
- DBI
- Debug
- Diff Browser
- Effect : Slideshow
- Engineering - Desing Pattern
- framework
- Framework - CodeIgniter
- Functions
- Imgick
- jquery
- JS Framework
- JS Library
- JS Object : Statement
- Linux
- Mapping Other Language
- Need to Turnning
- NetBeans
- OOAD-MVC
- open source suit software
- Performance
- Perl Installation
- PHP Class
- PHP rpc Java
- PHP to PERL
- Presentation
- RIA
- Serculity
- Service
- SQL injection
- Tips
- Tools
- Variable
- Versus
- WCF
- WebSite Thumbnail
- XML
- ZK Ajax