How can i convert this variable into string:

$var = __("Welcome");

because when i put in strpos function it will return an error:

strpos($var, 'om');

Uncaught TypeError: strpos() expects parameter 1 to be string, object given strpos(Object(Magento\Framework\Phrase)

1 Answer 1


This should work.

$var = __("Welcome")->render();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.