Code Table in CSS

danielneridanielneri WP V.I.P.VPS - Virtual Prince of the Server
anybody have any idea how people get those php boxes, "code" boxes??

for example if somebody was writing a tutorial, how do they get a box with a bunch of php code to be shown like normal html on a php page but with the php colours like dreamweaver shows?
ban1.gif

Comments

  • martian2k4martian2k4 Llama Hunter Moderator
    I can't remember the function for it so go have a look on http://www.php.net, Its pretty simple you put the code inside a string then have it echo it in a box yadda yadda.... Whats for lunch?
    Free MySpace Layouts- Coming soon
    Photoshop Tutorials- Coming soon
    Premium PHP Scripts- Coming soon

    Haha i should really do some work so i can remove all the coming soon's
  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    thanks for the quick reply but i have no idea how that answers my question lol
    and what do i search for on php.net?
    ban1.gif
  • PythonPython Forum Leader The Royal RAM
    hmmm... I used to know what it is aswell. Cant remember it now :(

    It colours the code appropiately and makes it look as it shoud... and because of what it is Im not sure what to type in to search for it...

    The Royal Ram

  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    damn...
    ban1.gif
  • martian2k4martian2k4 Llama Hunter Moderator
    Ok to get it to show PHP you need Highligh_String

    [PHP]<?php

    $str = "<? echo 'This is a string'; ?>";

    echo highlight_string($str);

    ?>[/PHP]
    Free MySpace Layouts- Coming soon
    Photoshop Tutorials- Coming soon
    Premium PHP Scripts- Coming soon

    Haha i should really do some work so i can remove all the coming soon's
  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    so i can include php code in that and it would appear and not execute?
    ban1.gif
  • PythonPython Forum Leader The Royal RAM
    yes... but watch out...when your putting the code into the variable as a string be careful of " characters because that would indicate to php that it is trying to end the current variable...

    The Royal Ram

  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    so could you give me an example with some php stuff in it please
    ban1.gif
  • PythonPython Forum Leader The Royal RAM
    well an example is what martain posted above... that is PHP code in a string, and then given to the function...

    The Royal Ram

  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    so this would work:

    [PHP]<?php

    $str = "<? echo 'This is a string.
    $foo = "foobar";'
    ; ?>";

    echo highlight_string($str);

    ?> [/PHP]
    ban1.gif
  • PythonPython Forum Leader The Royal RAM
    No... simply because the code your trying to display uses quotes "

    When PHP sees one of these quote characters in your code it thinks you are trying to end the variable.... in your case the variable $str

    So in the code you actually want to display replace all " with '

    That should then work me thinks ;)

    The Royal Ram

  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    ok thanks
    ban1.gif
  • kinkkink serious member VPS - Virtual Prince of the Server
    use a textarea and pre tags (cheap[ and easy)
  • xPureNLxxPureNLx Moderator The Royal RAM
    No offense, but hasn't this become a PHP-based question? :P
    signaru02am7.jpg
    [B]MSN: xPureNLx@gmail.com[/B]
    
  • DeluxeNamesDeluxeNames Admin Administrator
    xPureNLx wrote: »
    No offense, but hasn't this become a PHP-based question? :P

    Good point xPure, this has now been moved to the PHP section.
Sign In or Register to comment.