+ Reply to Thread
Results 1 to 3 of 3

Thread: How to highlight the php code

  1. #1
    Jacki's Avatar
    Jacki is offline Learning Programmer
    Join Date
    Sep 2009
    Location
    Switzerland
    Posts
    80
    Rep Power
    9

    How to highlight the php code

    Hi guys, there are two very useful functions that you can use in your website if you would write some php tutorials. These functions are: highlight_string and highlight_file wich highlighting the php code.

    For example:
    Code:
    highlight_string('<?php echo "Hello World!"?>');
    The output will be something like this html:
    HTML Code:
    <span style="color: rgb(0, 0, 187);">&lt;?php&nbsp;</span><span style="color: rgb(0, 119, 0);">echo&nbsp;</span><span style="color: rgb(221, 0, 0);">"Hello World!"</span><span style="color: rgb(0, 119, 0);">;&nbsp;</span><span style="color: rgb(0, 0, 187);">?&gt;</span>
    and will display something like:
    Code:
    <?php echo "Hello World!"?>
    There's also:
    Code:
    highlight_file("filetohighlight.php"); 
    That do the same thing with a file.

    I hope that you saw these functions for the first time and that this tutorial will be useful. Enjoy! Byez...



  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: How to highlight the php code

    Thanks for sharing. These functions make highlighting PHP very easy. For highlighting other languages, you can use GeSHi or Text_Highlighter from the Pear repos.

  4. #3
    Jordan Guest

    Re: How to highlight the php code

    Nice little tutorial. Easy, informative and to the point. +rep

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. CSS- Link Highlight Problem
    By bbqroast in forum Website Design
    Replies: 2
    Last Post: 10-31-2010, 06:23 PM
  2. HTML syntax highlight optimization?
    By CommittedC0der in forum C# Programming
    Replies: 0
    Last Post: 04-14-2010, 07:13 PM
  3. GeSHi to highlight code
    By dirkfirst in forum PHP Development
    Replies: 1
    Last Post: 07-19-2006, 02:03 PM

Tags for this Thread

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