what error?
You have not formatted the code in the question correctly, but it looks like invalid php to me
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
What is not working correctly in this embed youtube code below? Idea is that link for a youtube video is inserted from admin panel and then it should be displayed on main page. But it is showing error, the code is:
public function getDescription()
{
$description = $this->{'description_' . app()->getLocale()};
$description = preg_replace('/<figure class="media"><oembed url="https:\/\/youtu.be\/(.*?)"><\/oembed><\/figure>/', '<iframe width="560" height="315" src="https://www.youtube.com/embed/" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>', $description);
return $description;
Please or to participate in this conversation.