Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html src = a php variable

Hello I looked around a bit for a solution but couldn't find someone with the exact problem as me. Basically I have a php variable that is a url. I want to add a new iframe with that url.

This is what I have, but because HTML is using the double quotes after src the php variable is ignored.

<iframe width="420" height="345"src= "<?php $output ?>"> </iframe>

Thank you guys

like image 990
user3369289 Avatar asked Jul 05 '26 16:07

user3369289


1 Answers

<iframe width="420" height="345" src="<?php echo htmlspecialchars($output); ?>"> </iframe>

You're missing echo. Also, always use htmlspecialchars() to ensure you are creating valid HTML that isn't vulnerable to injection. If you find yourself doing this a lot, consider using a template engine.

like image 55
Brad Avatar answered Jul 08 '26 06:07

Brad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!