Title: Php call static method of class which is in variable
Tags: php;variables;namespaces
Question: I have a namespace ```App\Term``` which is saved as a property: ```$this-&gt;name = 'App\Term'```. How can I call a static method of this class like ```$this-&gt;nam181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16methodName()``` ? Or is there another solution for this problem?

Comment: Does `$nam181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16methodName()` not work?

Comment: I updated the question. It should be not a simple variable like `$name`. It is a property: `$this->name`

Here is the accepted answer: You can use ```call_user_func``` for this.

```call_user_func($name.'181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16methodName');
```

Or:

```call_user_func(array($name, 'methodName'));
```

Comment for this answer: Perfect. I works even with property: `call_user_func($this->name.'181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16methodName');`


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:10/22/15', 'FavoriteCount': 2.0, 'PostTypeId': 1, 'Tags': '<php><variables><namespaces>', 'Title': 'Php call static method of class which is in variable', 'ViewCount': 628, 'id': 33289615, 'user_AboutMe': '<p>I am a starting front-end developer. Learn JS, jQuery, CSS, HTML5, web-accessibility, semantic.\nI do programming almost all the day.</p>\n', 'user_AccountId': 6138141.0, 'user_DisplayName': 'FreeLightman', 'user_Reputation': 2124.0, 'user_Views': 263.0, 'user_id': 4786315.0}}