Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Syntax Highlighting

    i wanted to do something like this...

    ex.
    PHP Code:
    $dbhost "localhost";
    $dbname "DATABASE_NAME";
    $dbuser "USERNAME";
    $dbpass "PASSWORD"
    ^^ i want the PHP code to be highlighted even without the PHP tag ("<?php" "?>") is there a way to do that?

    i think i could use the highlight_string() function, but how would i display huge chunk of code like the example above

    something like this would work
    PHP Code:
     <?php
      $code 
    "echo \"Hello world!\";";
      
    highlight_string($code);
    ?>
    but thats only one a liner code..

    anyone can help me out? thanx in advance

  • #2
    Regular Coder
    Join Date
    Jun 2005
    Posts
    804
    Thanks
    0
    Thanked 0 Times in 0 Posts
    There's highlight_file(), but I don't know how/if removing your php tags will affect your output.

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Kid Charming
    There's highlight_file(), but I don't know how/if removing your php tags will affect your output.
    i tried highlight_file(), you need the php tag

  • #4
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    How about stripping the open/close tags after highlighting?
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #5
    New Coder
    Join Date
    Oct 2004
    Location
    NSW, Australia
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts
    LoL!, i was looking for this a while back, here is a link to a good highlighter you can modify, oh and you dont need the '<?php / ?>' tags, there optional!

    Website


  •  

    Posting Permissions

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