I'm trying to reuse variables in my CodeIgniter Model but I can't quite get the syntax down. The problem I'm having is on line 4.
class Products_model extends CI_Model {
var $gcsServerIpAddress = "11.22.33.44";
var $gcsServerAddress = "http://".$this->gcsServerIpAddress."/eft/";
I've tried object syntax: $this->foo
. I've also tried using the variable name: $foo
. Neither of them worked. Any suggestions?
Try to set the values inside the constructor.
class Products_model extends CI_Model {
var $gcsServerIpAddress;
var $gcsServerAddress;
function __construct(){
$this->gcsServerIpAddress = "11.22.33.44";
$this->gcsServerAddress = "http://".$this->gcsServerIpAddress."/eft/";
}
}