Use curly brackets like so:
$object->{'my_' . $variable}
More Related Contents:
- Writing PHP functions that has many parameters/modifiers [closed]
- What is the difference between public, private, and protected?
- PHP method chaining or fluent interface?
- Use global variables in a class
- Getter and Setter? [closed]
- Can I extend a class using more than 1 class in PHP?
- mysqli_query() expects parameter 1 to be mysqli, object given
- Why does PHP 5.2+ disallow abstract static class methods?
- When to use static vs instantiated classes
- mysql_fetch_array, mysql_fetch_assoc, mysql_fetch_object
- What is the syntax for accessing PHP object properties? [closed]
- Can you create instance properties dynamically in PHP?
- How to use objects from other namespaces and how to import namespaces in PHP
- Pre-declare all private/local variables?
- In PHP, can you instantiate an object and call a method on the same line?
- Understanding IoC Containers and Dependency Injection
- What is an abstract class in PHP?
- How do I get a PHP class constructor to call its parent’s parent’s constructor?
- php object attribute with dot in name
- When do I use static variables/functions in php?
- Getting static property from a class with dynamic class name in PHP
- What are the advantages of using getters and setters instead of functions or simply public fields in PHP? [closed]
- Magic __get getter for static properties in PHP
- What does the syntax ‘%s’ and ‘%d’ mean as shorthand for calling a variable?
- Is it possible to declare a method static and nonstatic in PHP?
- How to implement a decorator in PHP?
- Get all defined classes of a parent class in php
- Call method by string?
- How to create a fluent query interface?
- PHP equivalent of friend or internal