alexguz79 Posted May 11, 2010 Share Posted May 11, 2010 Greeting everyone... The issue is this... i have a php file that display data from mysql.. i want the source code of that page displayed in a textfield box so i can use that with a copy to clipboard button.. anyone can help? Quote Link to comment https://forums.phpfreaks.com/topic/201424-display-html-source-code-from-php/ Share on other sites More sharing options...
alexguz79 Posted May 11, 2010 Author Share Posted May 11, 2010 anyone please Quote Link to comment https://forums.phpfreaks.com/topic/201424-display-html-source-code-from-php/#findComment-1056815 Share on other sites More sharing options...
cyberRobot Posted May 12, 2010 Share Posted May 12, 2010 <form> <textarea name="code"> <?php echo '<html>'; echo '<body>'; echo '<p>Hello World</p>'; echo '<body>'; echo '</html>'; ?> </textarea> </form> Quote Link to comment https://forums.phpfreaks.com/topic/201424-display-html-source-code-from-php/#findComment-1057073 Share on other sites More sharing options...
Muddy_Funster Posted May 12, 2010 Share Posted May 12, 2010 or... <?php $source = file_get_contents(source.php) echo '<form>'; echo '<textarea name = "source">'; echo $source; echo '</textarea></form>'; ?> as for your "copy to clipboard" option, you'll need client side scripting like jscript, not php Quote Link to comment https://forums.phpfreaks.com/topic/201424-display-html-source-code-from-php/#findComment-1057078 Share on other sites More sharing options...
cyberRobot Posted May 12, 2010 Share Posted May 12, 2010 A simple solution to at least highlight the code would be: <form> <textarea name="code" onfocus="this.select();"> <?php echo '<html>'; echo '<body>'; echo '<p>Hello World</p>'; echo '<body>'; echo '</html>'; ?> </textarea> </form> Of course this solution doesn't do the copy part. I would need to brush up on my JavaScript to figure that out. Quote Link to comment https://forums.phpfreaks.com/topic/201424-display-html-source-code-from-php/#findComment-1057085 Share on other sites More sharing options...
.Stealth Posted May 12, 2010 Share Posted May 12, 2010 I looked into doing the copy to clipboard once and it wasn't that easy to do, due to browsers not wanting sites to access the clipboard for security reasons. Photobucket managed it but they did it with flash. There's a few scripts around for doing it but most are buggy. Quote Link to comment https://forums.phpfreaks.com/topic/201424-display-html-source-code-from-php/#findComment-1057220 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.