raydona Posted December 19, 2011 Share Posted December 19, 2011 Hi, I want to place the following HTML statement inside an echo statement, i.e. in PHP I want to output an image that is also a link. <a href="#"><img src="Somefolder/animage.jpg" width="125" height="156" alt="some image" /></a> All ideas will be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/253487-to-convert-html-to-php/ Share on other sites More sharing options...
Pikachu2000 Posted December 19, 2011 Share Posted December 19, 2011 So what's the problem? Quote Link to comment https://forums.phpfreaks.com/topic/253487-to-convert-html-to-php/#findComment-1299394 Share on other sites More sharing options...
QuickOldCar Posted December 19, 2011 Share Posted December 19, 2011 the following 2 methods can do this <?php echo "<a href='#'><img src='Somefolder/animage.jpg' width='125' height='156' alt='some image' /></a>"; echo "<a href=\"#\"><img src=\"Somefolder/animage.jpg\" width=\"125\" height=\"156\" alt=\"some image\" /></a>"; ?> but you can also break in and out of php if desire ?> <a href="#"><img src="Somefolder/animage.jpg" width="125" height="156" alt="some image" /></a> <?php Quote Link to comment https://forums.phpfreaks.com/topic/253487-to-convert-html-to-php/#findComment-1299405 Share on other sites More sharing options...
The Little Guy Posted December 19, 2011 Share Posted December 19, 2011 You can do this, then you don't have to escape your html quotes, and still use variables without having to concatinate: echo <<<OPT <a href="#"><img src="$phpVariable" width="125" height="156" alt="some image" /></a> OPT; Quote Link to comment https://forums.phpfreaks.com/topic/253487-to-convert-html-to-php/#findComment-1299414 Share on other sites More sharing options...
MasterACE14 Posted December 20, 2011 Share Posted December 20, 2011 or even... echo '<a href="#"><img src="' . $phpVariable . '" width="125" height="156" alt="some image" /></a>'; Quote Link to comment https://forums.phpfreaks.com/topic/253487-to-convert-html-to-php/#findComment-1299584 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.