PHP Developers Network
http://forums.devnetwork.net/

How do you show <img> tags on screen, as code?
http://forums.devnetwork.net/viewtopic.php?f=68&t=146321
Page 1 of 1

Author:  simonmlewis [ Mon Feb 12, 2018 11:24 am ]
Post subject:  How do you show <img> tags on screen, as code?

I want to provide the IMG code to someone on a webpage, without it rendering as an image.

ie.

<img src='.....' >/ And it show on screen as code.

How do you do it?

Author:  Christopher [ Mon Feb 12, 2018 12:00 pm ]
Post subject:  Re: How do you show <img> tags on screen, as code?

Syntax: [ Download ] [ Hide ]
$html_with_img = '<img src="....." >';
echo htmlspecialchars($html_with_img);

Author:  simonmlewis [ Thu Feb 15, 2018 11:59 am ]
Post subject:  Re: How do you show <img> tags on screen, as code?

For some reason, when I narrow the screen to mobile format, the text in the box goes off the screen, as it's not properly wrapping.
Is there a way to force it to wrap?

It's cause a horiz-slider on the browser.

Author:  Christopher [ Thu Feb 15, 2018 8:12 pm ]
Post subject:  Re: How do you show <img> tags on screen, as code?

Put <br> in the places you want it to wrap?

Author:  simonmlewis [ Fri Feb 16, 2018 2:51 am ]
Post subject:  Re: How do you show <img> tags on screen, as code?

Sorry?
The resulting code being rendered is random.

Author:  Christopher [ Fri Feb 16, 2018 4:37 pm ]
Post subject:  Re: How do you show <img> tags on screen, as code?

It is not wrapping because there are long stretches of characters without a space. You can manually wrap it at a specific length, or use Javascript to wrap it based on the width of the window.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/