By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 1,783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

First Go at Classes

P: n/a
So, here I am, I've been programming PHP for 6 years, and have never
gotten into classes. Well, I finally decided to take the plunge, and
here's my very first newbie question. How come this works (not in a
class):

$x = array("a" => array(), "b" => array());
$z = &$x['b'];
$x['b'][0] = "test";
echo $z[0];

And this doesn't:

class Phorm {
var $dSpace, $dEmail, $dValid, $dAckPg, $dDBLog, $dTXLog;

function PhormProcessor() {
$this->dSpace = array(
"EMail" => array(),
"Valid" => array(),
"AckPg" => array(),
"DBLog" => array(),
"TXlog" => array()
);

$this->dEmail = &$this->dSpace['EMail'];
$this->dValid = &$this->dSpace['Valid'];
$this->dAckPg = &$this->dSpace['AckPg'];
$this->dDBLog = &$this->dSpace['DBLog'];
$this->dTXLog = &$this->dSpace['TXlog'];
}
}

$Phorm = new Phorm;

$Phorm->dSpace['Email'][0] = "test";

echo $Phorm->dEmail[0];

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Carved in mystic runes upon the very living rock, the last words of Alan
Little of comp.lang.php make plain:
And this doesn't:

class Phorm {
var $dSpace, $dEmail, $dValid, $dAckPg, $dDBLog, $dTXLog;

function PhormProcessor() {


Sorry, it's supposed to be:

class Phorm {
var $dSpace, $dEmail, $dValid, $dAckPg, $dDBLog, $dTXLog;

function Phorm() {

I changed the name of the class without changing the name of the
constructor. But it still isn't working.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Jul 17 '05 #2

P: n/a
Carved in mystic runes upon the very living rock, the last words of Alan
Little of comp.lang.php make plain:
$this->dSpace = array(
"EMail" => array(),

$Phorm = new Phorm;

$Phorm->dSpace['Email'][0] = "test";

echo $Phorm->dEmail[0];


Gaaaahhh! Forget it! Wrong array key. Now I really do feel like a newbie.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.