newbtophp Posted September 21, 2009 Share Posted September 21, 2009 I've been trying to use highlight_string within textarea tags, but the highlighted code is not contained within the textarea it explodes Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted September 21, 2009 Share Posted September 21, 2009 I don't believe what you are trying to do is possible, but I am not entirely sure what you are trying to do. post your code please Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 21, 2009 Share Posted September 21, 2009 A textarea, like its' name states, is just for text. Any characters, including the HTML formatting characters that highlight_string() adds will be literally displayed. Quote Link to comment Share on other sites More sharing options...
newbtophp Posted September 21, 2009 Author Share Posted September 21, 2009 <?php $string = "<?php echo 'see it aint highlighted, the html tags from the highlight_string function interfer ';"; echo '<textarea style="width:100%; height:300px;">'; highlight_string($string); echo '</textarea>'; ?> Is their any other way of making it function and look like a textarea? (with the same style) any alternative perhaps? :-\ Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted September 21, 2009 Share Posted September 21, 2009 I don't believe so. a textarea is basically a tiny version of a text editor (a very simple text editor) and so you can only edit the text as plain text. not to mention that highlight_string() returns your string with style tags around it for example the following <html> <body> <?php highlight_string("Hello world! <?php phpinfo(); ?>"); ?> </body> </html> would return <html> <body> <code> <span style="color: #000000">Hello world! <span style="color: #0000BB"><?php phpinfo</span> <span style="color: #007700">(); </span> <span style="color: #0000BB">?></span> </span> </code> </body> </html> Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted September 21, 2009 Share Posted September 21, 2009 If you just want to be able to scroll you can set overflow:auto; and some sort of (max-)width/height. Quote Link to comment Share on other sites More sharing options...
newbtophp Posted September 21, 2009 Author Share Posted September 21, 2009 If you just want to be able to scroll you can set overflow:auto; and some sort of (max-)width/height. I tried that and is as good as. Just a few issues though. Im trying to disable the horizontal scroll (without hiding), so it just scroll vertically like a textarea. I tried: overflow-x: hidden; overflow-y: scroll; But that hides the horizontal scroll and the lines are overlapping into the hidden area. Is their anyway i can manipulate it so it dont scroll horizontal, it proceeds to next line in the frame. (like textarea) Thanks Quote Link to comment Share on other sites More sharing options...
thebadbad Posted September 21, 2009 Share Posted September 21, 2009 You would have to look into word wrapping. But it would mess up the layout of the code. Example: //$php contains PHP code $high = highlight_string($php, true); //convert non-breaking spaces to regular spaces $high = str_replace(' ', ' ', $high); echo '<div style="overflow: auto; width: 300px; height: 100px;">' . $high . '</div>'; Quote Link to comment Share on other sites More sharing options...
newbtophp Posted September 23, 2009 Author Share Posted September 23, 2009 Thanks Solved Quote Link to comment 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.