Simplest method using value objects which is considered a best practice when converting from a struct type.
class MSG_HEAD
{
var $c, $size, $headcode;
}
class GET_INFO
{
var $h, $Type, $Port, $Name, $Code;
function __construct() {
$this->h = new MSG_HEAD();
}
}
function Example (GET_INFO $msg)
{
print ($msg->Name);
print ($msg->Code);
}
Using Getters and setters which is a bit more advanced but should allow for it to act more like a struct
class MSG_HEAD
{
protected $c;
protected $size;
protected $headcode;
function __get($prop) {
return $this->$prop;
}
function __set($prop, $val) {
$this->$prop = $val;
}
}
class GET_INFO
{
protected $MSG_HEAD;
protected $Type;
protected $Port;
protected $Name;
protected $Code;
function __construct() {
$this->MSG_HEAD = new MSG_HEAD();
}
function __get($prop) {
return $this->$prop;
}
function __set($prop, $val) {
$this->$prop = $val;
}
}
function Example (GET_INFO $msg)
{
print ($msg->Name);
print ($msg->Code);
}