A
A
Artur Yalaltdinov2015-12-07 02:07:02
PHP
Artur Yalaltdinov, 2015-12-07 02:07:02

How to change the function call?

Hello everyone, there is a function that displays a value from an IPB 3.4.x array

public function getUser($param)
  {
    $IPSMember = new IPS();
    $IPSMember->init();
    $member = $IPSMember->getMember();
    return $member[$param];
  }

I call it like this
$member->getUser('member_id');
I need to do the same but in IPS 4.x
at the moment it is called like this
$member = \IPS\Member::loggedIn();
echo $member->member_id;

The question is how to extract an element from an array as in IPB 3.4.x?
i.e
public function getUser($param)
  {
    $member = \IPS\Member::loggedIn();
return $member->[$param];//Пример
  }

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
Cat Anton, 2015-12-07
@crazy_str

public function getUser($param)
{
    return \IPS\Member::loggedIn()->{$param};
}

H
holfza, 2015-12-07
@holfza

$member->{$param};

D
Dave, 2015-12-07
@djay

Or more concisely:
call_user_func(array($member, $param))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question