SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: PHP code in div

  1. #1
    SitePoint Addict scoobasteve1982's Avatar
    Join Date
    Apr 2007
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow PHP code in div

    I was wondering if anyone knew where I can show code to my users in a scrolling div (cross browser too) that will format the code and highlight colors. I've always wondered how people do this. You should be able to see an example of what I mean below..

    PHP Code:
    function testFoo() {

    echo 
    "I would like to use this code display box on my site!";


    See what I mean...thanks!

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    A scrolling div requires dimensions and overflow:scroll.For code like this, you would most likely want it to scroll horizontally and vertically, so you would have to give it a width and a maximum height (note that IE6 doesn't know about CSS's max-height so on the server side you might have to count the number of lines being outputted and set the height based on that).

    Then use highlight_string().

    This might be worth a look too: http://www.sitepoint.com/article/hig...ource-code-php

  3. #3
    SitePoint Addict scoobasteve1982's Avatar
    Join Date
    Apr 2007
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you but what about highlighting say HTML code?

  4. #4
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Look at the second link, they recommend using the PEAR package that'll highlight any language on the face of the Earth.

  5. #5
    SitePoint Addict scoobasteve1982's Avatar
    Join Date
    Apr 2007
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I apologize about responding that way, I visited the link after I posted the question..argh! Thanks buddy..

  6. #6
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No worries.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •