XF 2.2 I want a phrase, and get an universe?

Robert9

Well-known member
It seems I do something wrong here, but I don't understand how and why.


Code:
$descriptionPhrase = "phrasename123";
echo \XF::phrase($descriptionPhrase);

shows something like "blablabla" = content of phrase with the name in $descriptionPhrase


Code:
$upgradeDescription[$userUpgradeId]['description'] = "99";

Code:
echo $upgradeDescription[$userUpgradeId]['description']

shows 99


Code:
$upgradeDescription[$userUpgradeId]['description'] = \XF::phrase($descriptionPhrase);

Cant echo this, must print_r this;

When I print_r this, get a universe of an array.

How is this possible, please?
 
Last edited:
Hmm, ok, means every phrase have another 100 information around this phrase.
A phrase is never just "blabla", the text I have insert.
 
A XenForo phrase created in PHP code is an instance of class \XF\Phrase.

If you want it's string representation, you can just cast it to a string (as the class implements __toString magic method):
PHP:
$upgradeDescription[$userUpgradeId]['description'] = (string)\XF::phrase($descriptionPhrase);

But you can just echo it as well
PHP:
echo(\XF::phrase($descriptionPhrase));
 
Thank you very much; as long I don't need all the stuff, it is better to have just the sentences.
The add-on is online now, I will do an update later. Thank you again.

 
Back
Top Bottom