Greetings, there is PHP code, the problem is that when I call the GetInventory() method, GetInventory() pass the parameter, but I need to make sure that if the parameter is not passed, I assign the standard values of $this->param , but this does not work for me.
class steam{ private $Bots_ID = array(); private $Weapons = array(); private $param = array('id','name','quality','market_name'); private $SteamID = 0; private $Link = "http://steamcommunity.com/profiles/[steamid]/inventory/json/730/2"; public function __construct($bots_id = array()){ $this->Bots_ID = $bots_id; } public function GetInventory($param = $this->param){ $this->SteamID = 1234567890; $this->param = $param; $data = json_decode(file_get_contents( preg_replace("/\[steamid\]/i", $this->SteamID, $this->Link) ), true); for ($i = 0; $i < count($data['rgInventory']); $i++) { $element_name = array_shift($data['rgInventory']); $code_item = $element_name['classid']."_".$element_name['instanceid']; $this->Weapons[$i]['id'] = $element_name['id']; } return $this->Weapons; } } $steam = new steam(); $items = $steam->GetInventory(); print_r($items); ?>
if (!$param) $param = $this->param:) - Vasily Barbashev