showing code - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: showing code (/showthread.php?tid=2215) |
showing code - El Forum - 07-23-2007 [eluser]St0neyx[/eluser] Hi all, I'm making an Code Igniter help site for my work, i'm the first who's working/testing codeigniter and want to make some code examples and stuff.. (also makes me more experienced with CI) now is my question.. how do i print out code like this (and i mean what you see the php code with colors and all) Code: <?php echo 'example code'; ?> showing code - El Forum - 07-23-2007 [eluser]batteries[/eluser] have you checked the manual? it should have something in there. showing code - El Forum - 07-23-2007 [eluser]gunter[/eluser] yes, I think there was something... maybe try: highlight_string(String); highlight_file (File); ahhh! search in the user_guide for: highlight_code() showing code - El Forum - 07-23-2007 [eluser]batteries[/eluser] i was trying to teach a man how to fish.. and you ruined it by giving it to him showing code - El Forum - 07-23-2007 [eluser]esra[/eluser] You might also look as the Geshi library. (Do a web search). showing code - El Forum - 07-24-2007 [eluser]St0neyx[/eluser] [quote author="batteries" date="1185242797"]have you checked the manual? it should have something in there.[/quote] [quote author="batteries" date="1185244941"]i was trying to teach a man how to fish.. and you ruined it by giving it to him [/quote] I did look at the forums and userguide.. ;-) I always do that, but could'n find it.. thats why i posted it.. showing code - El Forum - 07-24-2007 [eluser]St0neyx[/eluser] [quote author="gunter" date="1185244684"]yes, I think there was something... maybe try: highlight_string(String); highlight_file (File); ahhh! search in the user_guide for: highlight_code()[/quote] Thx i will look at it Edit: Hmm it works half.. if i do this Code: $string = and if i print out the code this is the result function index() { // definde the page array Array = array(); Array = array(); // define the header content and footer // load the page Object id #10->view('index', Array); } you can see my page and data arrays are different and the this->load->view is different showing code - El Forum - 07-24-2007 [eluser]pr0digy[/eluser] You can also use JavaScript for this. Here is a nice little library - code prettify. I use it on my site. showing code - El Forum - 07-24-2007 [eluser]glemigh[/eluser] I found this somewhere, and hacked it up for my needs, maybe you can get some ideas from it. source.php Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" showing code - El Forum - 07-24-2007 [eluser]glemigh[/eluser] and the css, source.css is to big to paste into a message, so I tar'ed up both and you can grab it here: source_show.tgz Hope it helps you in some way torwards your goal. George |