redarrow Posted February 22, 2008 Share Posted February 22, 2008 advance thank you...... I am in the process off creting a forum and i want to show raw php code syntex.... I have got this far using the highlight_string function()....... is there any other function to show code off to pearing eyes cheers...... <?php $code='<?php //$number varable is set to 1. $number=1; //$number varable is now incremented by 1 using the ++ sign. $number++; // result of number is 2 becouse we add 1 by the ++ sign called increment. echo $number; //please copy and paste the code to see the results.... ?>'; if (eregi("^(\<\?php|\<\?)",$code)){ highlight_string($code); echo $code; }else{ echo 'Sorry your php opening tag has to be in order of <? or this <?php'; exit; } ?> <p></p> <?php $number=1; $number++; echo "the result off \$number is: $number"; ?> Link to comment https://forums.phpfreaks.com/topic/92480-hightlighting-a-string-quistion-and-example/ Share on other sites More sharing options...
Bauer418 Posted February 22, 2008 Share Posted February 22, 2008 From what I can grasp, you want another function to color-code your PHP syntax? There are plenty out there, but may I ask why highlight_string isn't working out for you? Are you looking for support for other coding languages, or do you want to change the colors of the syntax? (Syntax colors can be set through php.ini), such as: ini_set ('highlight.string', '#000000'); ini_set ('highlight.comment', '#FF8000'); ini_set ('highlight.keyword', '#00FF00'); ini_set ('highlight.bg', '#CCCCCC'); ini_set ('highlight.default', '#DDDDDD'); ini_set ('highlight.html', '#EEEEEE'); Link to comment https://forums.phpfreaks.com/topic/92480-hightlighting-a-string-quistion-and-example/#findComment-473796 Share on other sites More sharing options...
redarrow Posted February 22, 2008 Author Share Posted February 22, 2008 can you exsplain the concept off the colors and there acting function example ini_set ('highlight.string', '#000000'); <<< what they relate to why the joiing . ini_set ('highlight.comment', '#FF8000');<< what the funtion highlight.comment do and others cheers..... ini_set ('highlight.keyword', '#00FF00'); ini_set ('highlight.bg', '#CCCCCC'); ini_set ('highlight.default', '#DDDDDD'); ini_set ('highlight.html', '#EEEEEE'); is this css but using the function highlight string() sorrry but i really like to no all for future refrence cheers regards redarrow.... Link to comment https://forums.phpfreaks.com/topic/92480-hightlighting-a-string-quistion-and-example/#findComment-473805 Share on other sites More sharing options...
Bauer418 Posted February 22, 2008 Share Posted February 22, 2008 They're not functions, they're PHP global settings for the highlight_string function. highlight.comment changes the color of comments, highlight.string changes the color of strings. This applies to any code passed through highlight_string. Link to comment https://forums.phpfreaks.com/topic/92480-hightlighting-a-string-quistion-and-example/#findComment-473808 Share on other sites More sharing options...
redarrow Posted February 22, 2008 Author Share Posted February 22, 2008 i uderstand php very well, i am learning new functions as i go on, so i need to no what the highlight.string,highlight.keyword ect ect relate to for showing purpose.... i understand the color is passed to the highlight_string() function but in relation to the colors what do they change for example hightlight.html does that mean all html is that color now... sorry i am currently in a internet cafe, So i am blind to see my own examples..... Link to comment https://forums.phpfreaks.com/topic/92480-hightlighting-a-string-quistion-and-example/#findComment-473813 Share on other sites More sharing options...
Bauer418 Posted February 22, 2008 Share Posted February 22, 2008 As I just said, when you change the value of the setting highlight.string, every string present in the text passed to hightlight_string will be colored to whatever is set. The same applies to highlight.html, and the other customizable settings. Link to comment https://forums.phpfreaks.com/topic/92480-hightlighting-a-string-quistion-and-example/#findComment-473816 Share on other sites More sharing options...
redarrow Posted February 22, 2008 Author Share Posted February 22, 2008 example what the rest do as there not showing....... ini_set ('highlight.string', 'brown'); ini_set ('highlight.comment', 'gray');//-------- highlights all php comments ini_set ('highlight.keyword', 'pink');//-------highlights any php charecters and operaters ini_set ('highlight.bg', 'yellow'); ini_set ('highlight.default', 'blue');//-------- hightlights all php varables ini_set ('highlight.html', 'red'); Link to comment https://forums.phpfreaks.com/topic/92480-hightlighting-a-string-quistion-and-example/#findComment-473833 Share on other sites More sharing options...
Bauer418 Posted February 22, 2008 Share Posted February 22, 2008 For the third time, highlight.string highlights all strings inside the PHP code. A string is quoted text. highlight.bg changes the background color for the highlighted code, and highlight.html highlights all HTML code. Link to comment https://forums.phpfreaks.com/topic/92480-hightlighting-a-string-quistion-and-example/#findComment-473841 Share on other sites More sharing options...
redarrow Posted February 22, 2008 Author Share Posted February 22, 2008 What i was trying to do is enter text and php code, when it finds the code charecters it hightlights the code to bee shown to browser..... <?php //database connection if($_POST['submit']){ $x=$_POST['x']; $m=htmlspecialchar($x); $sqla="insert into(id,m)VALUES('$id','$m')"; $resulta=mysql_query($sqla) or die(mysql_error()); echo" <br> Thank you database entry entered <br> "; $sqlb="select * from test"; $resultb=mysql_query($sqlb) or die(mysql_error()); while($k=mysql_fetch_assoc($resultb)){ $resultc=mysql_query($sqlc) or die(mysql_error()); if(eregi("(\[\code\])*(\[\\code])",$k['x'])){ heightlight_string($k['x']); } } } ?> Link to comment https://forums.phpfreaks.com/topic/92480-hightlighting-a-string-quistion-and-example/#findComment-473875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.