I want to share a object between two static functions in a class with out pass through parameters. for example in my class have to static function ProfileRegistration()
it get a object through parameter and I want to call another function Format()
it process the same object. I want to call the Format()
function without
passing the object
once again
I don't know share the value between to function, so I Pass it as a parameter. How to avoid it?
class SMSList {
var $objLogin;
public function __construct()
{
}
public static function ProfileRegistration($objLogin)
{
$objself=new self();
$objself->objLogin=$objLogin;
$obj=new SMSMessage();
if($obj->profile_registration_sms_status==1)
{
$msg=self::Format($obj->profile_registration_sms,$objself-objLogin);
return SMS::sendSMS($objself->objLogin->mobile,$msg);
}
}
public function Format($message,$objLogin)
{
$message=str_replace('#NAME#',$objLogin->contact_person,$message);
$message=str_replace('#COMP_NAME#',$objLogin->companyname,$message );
$message=str_replace('#MOBILE#',$objLogin->mobile,$message);
$message=str_replace('#CITY#',$objLogin->city,$message);
$message=str_replace('#EMAILID#',$objLogin->emailid,$message);
return $message;
}
}
Solve this problem using static variable. code example here