"new" keyword/construction in UDTs
Posted: Mon Dec 08, 2008 7:20 pm
Hi there,
I am a bit new to PHP and CMS Made Simple, so this is perhaps a newbie question. Appropriately enough, it concerns new and constructors. My background is in C and C++ so it's quite likely I am making assumptions about how they work that are wrong.
I'm working on a UDT in CMS Made Simple 1.4.1 on PHP 5.1.6. I have built a very simple XML file for use in a site; basically it contains contact details for various site offices, and each one has an ID which corresponds to a site id field in a SQL database. I plan to grab the id, I use it to select the appropriate bit of the xml and I print the bits into a table.
Since the version of PHP I have is over five, I thought I would use the DOM, and found a nice (so I suppose) tute here:
http://devzone.zend.com/node/view/id/1713#Heading8
It suggests loading your XML using
$dom = new DomDocument();
$dom->load("articles.xml");
I have stuck something very similar into my UDT (identical barring variable and file names, basically) and I have discovered that it stops working around the point of the first statement (the construction statement). Moving it up the file kills everything after it, and that goes with everything commented out but the construction statement, so it's definitely the actual construction that is causing the grief. It seems to parse fine. I also found that the class is actually DOMDocument so I changed the capitalization; no effect.
Anyway, I had had problems with global variables earlier (I had to specify they were global within the UDT, which I didn't think you had to do if you declared them outside a function) so I wondered if UDTs mess around with memory management in some way? Alternatively, do I have to tell the UDT to use the DOM in a sort of #include kind of a way? Is it something compeltely different?
Thanks!
I am a bit new to PHP and CMS Made Simple, so this is perhaps a newbie question. Appropriately enough, it concerns new and constructors. My background is in C and C++ so it's quite likely I am making assumptions about how they work that are wrong.
I'm working on a UDT in CMS Made Simple 1.4.1 on PHP 5.1.6. I have built a very simple XML file for use in a site; basically it contains contact details for various site offices, and each one has an ID which corresponds to a site id field in a SQL database. I plan to grab the id, I use it to select the appropriate bit of the xml and I print the bits into a table.
Since the version of PHP I have is over five, I thought I would use the DOM, and found a nice (so I suppose) tute here:
http://devzone.zend.com/node/view/id/1713#Heading8
It suggests loading your XML using
$dom = new DomDocument();
$dom->load("articles.xml");
I have stuck something very similar into my UDT (identical barring variable and file names, basically) and I have discovered that it stops working around the point of the first statement (the construction statement). Moving it up the file kills everything after it, and that goes with everything commented out but the construction statement, so it's definitely the actual construction that is causing the grief. It seems to parse fine. I also found that the class is actually DOMDocument so I changed the capitalization; no effect.
Anyway, I had had problems with global variables earlier (I had to specify they were global within the UDT, which I didn't think you had to do if you declared them outside a function) so I wondered if UDTs mess around with memory management in some way? Alternatively, do I have to tell the UDT to use the DOM in a sort of #include kind of a way? Is it something compeltely different?
Thanks!