Valrus Posted November 18, 2008 Share Posted November 18, 2008 Ok, I'm admittedly new to php. This seems like a small thing, but it doesn't appear to work in php. class mcuTransBuilder { public $mcuToken; public $userToken; public $common; function __construct() { //create a single Common Parameter class. $common = new buildCommonTrans(); print "constructor object created"; } /* Sets mcu returned tokens for future transactions */ function setSessionTokens($MCU, $User) { print "Inside function"; $this->common->setTokens($MCU,$User); } function createLogin($loginName, $password) { $login = new buildTrans_Login(); return $login->buildXMLString($loginName,$password, $common); } } Basically common is another class that is supposed to hold and do a few functions that will be used in a lot of other calls. However, for some reason when I try to call setTokens in the setSessionTokens method it just stops processing there. I can do the call in the constructor fine, but I'd really like to know why it won't do it in another method. I've tried it several different ways in terms of syntax, so I'm thinking something else is at work here. Quote Link to comment https://forums.phpfreaks.com/topic/133245-problem-using-classes/ Share on other sites More sharing options...
KevinM1 Posted November 18, 2008 Share Posted November 18, 2008 In your constructor, it should be: $this->common = new buildCommonTrans(); Also, you should set your data members as private, just to ensure that they aren't directly accessed. Quote Link to comment https://forums.phpfreaks.com/topic/133245-problem-using-classes/#findComment-692967 Share on other sites More sharing options...
Valrus Posted November 19, 2008 Author Share Posted November 19, 2008 Thanks, I figured it was something simple. Quote Link to comment https://forums.phpfreaks.com/topic/133245-problem-using-classes/#findComment-693476 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.