Vebers Posted October 2, 2006 Report Share Posted October 2, 2006 Ir iespējams caur klasi izveidot pašā klasē jaunu memberi (mainīgo) caur metodi (funkciju) ? Ideāls piemērs būtu SimpleXML. Link to comment Share on other sites More sharing options...
bubu Posted October 2, 2006 Report Share Posted October 2, 2006 $this->x = 1; ? Link to comment Share on other sites More sharing options...
Delfins Posted October 2, 2006 Report Share Posted October 2, 2006 kas attiecās uz PHP, tu vari veidot cik vien vēlies memberu... nav strikta valoda. $x->aa = 1; vai $x->newAaa(); { $name = 'mans_aa_'.$this->aaaCount; $this->$name = 1; $this->aaaCount++; } Link to comment Share on other sites More sharing options...
Vebers Posted October 2, 2006 Author Report Share Posted October 2, 2006 Nē, šķiet ka nesaprati. SimpleXML ir tā, ka ielasot XML failu automātiski klasē izveidojas memberi. piem., ja XML faila saturs ir: <?xml version='1.0' standalone='yes'?> <movies> <movie> <title>PHP: Behind the Parser</title> <characters> <character> <name>Ms. Coder</name> <actor>Onlivia Actora</actor> </character> <character> <name>Mr. Coder</name> <actor>El ActÓr</actor> </character> </characters> <plot> So, this language. It's like, a programming language. Or is it a scripting language? All is revealed in this thrilling horror spoof of a documentary. </plot> <rating type="thumbs">7</rating> <rating type="stars">5</rating> </movie> </movies> Un kā tas izskatās: echo $xml->movie[0]->title Ideja skaidra ? Link to comment Share on other sites More sharing options...
bubu Posted October 2, 2006 Report Share Posted October 2, 2006 manuālīti vajag palasīties.. $a = "blah"; $$a = "xxx"; echo $blah; Link to comment Share on other sites More sharing options...
Vebers Posted October 2, 2006 Author Report Share Posted October 2, 2006 Paldies! Link to comment Share on other sites More sharing options...
Kaitnieks Posted October 2, 2006 Report Share Posted October 2, 2006 $this->movie = new xmlmember(); vai $this->$paramname = new xmlmember(); un ģenerē propertijus dinamiski. tipa tā? Link to comment Share on other sites More sharing options...
Recommended Posts