Like this
<?php
$prop = 'Name';
echo $obj->$prop;
Or, if you have control over the class, implement the ArrayAccess interface and just do this
echo $obj['Name'];
More Related Contents:
- What is the syntax for accessing PHP object properties? [closed]
- Accessing Class Properties with Spaces
- Getting static property from a class with dynamic class name in PHP
- Magic __get getter for static properties in PHP
- How do I check if a string contains a specific word?
- PHP method chaining or fluent interface?
- startsWith() and endsWith() functions in PHP
- PHP – concatenate or directly insert variables in string
- How to remove accents and turn letters into “plain” ASCII characters? [duplicate]
- Convert a comma-delimited string into array of integers?
- How do I remove all specific characters at the end of a string in PHP?
- Dollar ($) sign in password string treated as variable
- Replace last occurrence of a string in a string
- How can I check if a word is contained in another string using PHP?
- Converting a number (1, 2, 3) to a string (one, two, three) in PHP
- Remove a string from the beginning of a string
- If Singletons are bad then why is a Service Container good?
- How can I remove part of a string in PHP? [closed]
- How to use class methods as callbacks
- PHP String Manipulation: Extract hrefs
- Get last whole number in a string
- Include constant in string without concatenating
- Remove Trailing Slash From String PHP
- Explode a paragraph into sentences in PHP
- How do I get the byte values of a string in PHP?
- Unresolvable dependency resolving [Parameter #0 [ $name ]]
- Access object property with disallowed character in property name
- How to validate that a string only contain lowercase letters?
- Regex to match an IP address [closed]
- How do I detect non-ASCII characters in a string?