Jump to content

HTML in PHP variables


wintallo

Recommended Posts

Hey,

How can I make it so full HTML code (with quotes and everything) can be stored in a PHP variable.

This is the kind of HTML i will be storing is

[code]
<object height="525" width="700"><param name="movie" value="../game-movie/motion.swf" />
<embed src="../game-movie/motion.swf" height="525" width="700"></object>
[/code]

or maybe

[code]
<embed style="width: 400px; height: 326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=4092819850988013212" quality="best" bgcolor="#ffffff" scale="noScale" salign="TL" flashvars="playerMode=embedded" align="center">
[/code]

I tried this

[code]
<?php

$moviehtml = addslashes( "<object height="525" width="700"><param name="movie" value="../game-movie/motion.swf" />
<embed src="../game-movie/motion.swf" height="525" width="700"></object>" );

echo $moviehtml;
echo "testing...";

?>
[/code]
But it doesn't even output the "testing..."

Thanks for the read and if you don't get what I'm saying, please reply.

-Joel
Link to comment
https://forums.phpfreaks.com/topic/36423-html-in-php-variables/
Share on other sites

Add slashes doesn't work like that :(...

It would cause an error because of the quotes... I suggest something like

$moviehtml = '<object height="525" width="700"><param name="movie" value="../game-movie/motion.swf" />
<embed src="../game-movie/motion.swf" height="525" width="700"></object>';

Or if your variable is going to have single quotes, I suggest using $tag = "<htmltag var=\"val\">";
Link to comment
https://forums.phpfreaks.com/topic/36423-html-in-php-variables/#findComment-173282
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.