Adding PHP code in HTML which is already in PHP? -


basically, want add php variable in html, html being inserted constant, in php code. here's mean: (obviously code below wrong, imagine want inserting $variable in url of iframe, example)

<?php $variable = 'example-sub-category'; const example = "<iframe src='http://example.com/$variable'></iframe>"; ?> 

what syntax adding variable in there?

thanks in advance!

this basic template. str_replace() should trick.

const example = "<iframe src='http://example.com/{{{variable}}}'></iframe>"; $variable = 'example-sub-category  $merged_content = str_replace('{{{variable}}}', $variable, example); 

note used {{{}}} denote insert. not php syntax, find templates use not expected in text otherwise denote placeholders.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -