TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-16-2009, 03:15 PM   #1 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,267
Thanks: 90
Wildhoney is on a distinguished road
Application Go Prettifying Pasted Code on TalkPHP

You may notice that when you post code, you can wrap it in a few BBCodes. Mostly we use [code], [php] and [highlight], as described below.

Some people, however, don't wrap their code in any BBCodes at all, which ends up looking messy, and likely to immediately deter people from reading your code, thus replies will be scarce.

Option 1: [code]

At the very least we should be using this BBCode because at least it preserves white-space, tabbing being the most important. However, when using this BBCode, there is no colour highlighting and so whilst it's acceptable, it's not perfect.

This really should be limited to code that is in a language that is unsupported by any other of our BBCodes. Pseudo code, for instance.

Option 2: [php]

As this is a PHP forum, if you hadn't noticed, I imagine most people will want to use this tag. It is the most popular, and will get the job done nicely. It has all the advantages of the aforementioned BBCode, but with the added nicety of PHP syntax highlighting.

This, whilst more than fine, is not quite as advanced as the last of the BBCode tags, but when it comes to PHP highlighting, this or the subsequent will be more than appreciated.

One thing though, please do not use this tag for non-PHP code, as the highlighting will likely resemble that of a firework in a paint pot.

Option 3: [highlight]

This BBCode is something I added to TalkPHP because it allows for much more advanced syntax highlighting. I use this for PHP as well because I find it looks nicer than the antecedent BBCode, but each to their own.

The highlight BBCode uses Geshi syntax highlighting, which supports a wide-range of programming languages. To specify the language you wish to place in between the BBCode tags, you can do the following. For example, if you wish to show PHP:

[highlight=php]/* PHP code */[/highlight]

Albeit this is not a comprehensive list of supported languages, but the ones that are most common on TalkPHP:
  • highlight=php (PHP)
  • highlight=javascript (JavaScript)
  • highlight=html4strict (HTML)
  • highlight=css (CSS)
  • highlight=xml (XML)
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.

Last edited by Wildhoney : 06-25-2009 at 07:49 PM.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-17-2009, 08:07 AM   #2 (permalink)
The Contributor
 
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
rguy84 is on a distinguished road
Default

GeSHi is great, I have it installed on my site. Do we use highlight within php bbcode?
__________________
Ryan | Blog | Twitter
Send a message via AIM to rguy84 Send a message via MSN to rguy84 Send a message via Yahoo to rguy84 Send a message via Skype™ to rguy84
rguy84 is offline  
Reply With Quote
Old 06-17-2009, 11:19 AM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,267
Thanks: 90
Wildhoney is on a distinguished road
Default

You specifying the language using the highlight tag.

[highlight=php]

__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-17-2009, 06:11 PM   #4 (permalink)
The Contributor
 
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
rguy84 is on a distinguished road
Default

no sorry, I meant do we nest it within other tags? I posted some php with some html inside of it, the html showed up as plain text.
__________________
Ryan | Blog | Twitter
Send a message via AIM to rguy84 Send a message via MSN to rguy84 Send a message via Yahoo to rguy84 Send a message via Skype™ to rguy84
rguy84 is offline  
Reply With Quote
Old 06-17-2009, 06:52 PM   #5 (permalink)
The Addict
 
adamdecaf's Avatar
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

Because HTML is not PHP, they are separate languages.
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 06-17-2009, 07:21 PM   #6 (permalink)
The Contributor
 
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
rguy84 is on a distinguished road
Default

well yes, I am asking would we use highlight within the php tag to nab the html.
__________________
Ryan | Blog | Twitter
Send a message via AIM to rguy84 Send a message via MSN to rguy84 Send a message via Yahoo to rguy84 Send a message via Skype™ to rguy84
rguy84 is offline  
Reply With Quote
Old 06-17-2009, 08:12 PM   #7 (permalink)
The Addict
 
adamdecaf's Avatar
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

Well, we can try.

php Code:
<?php
// highlight=php
function hello(){
    print "Hello World!";
}
?>
<p>
   <?php
     hello();
   ?>
</p>

PHP Code:
<?php
// php
function hello(){
    print 
"Hello World!";
}
?>
<p>
   <?php
     hello
();
   
?>
</p>
Code:
<?php
// code
function hello(){
    print "Hello World!";
}
?>
<p>
   <?php
     hello();
   ?>
</p>
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 06-25-2009, 11:47 AM   #8 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,267
Thanks: 90
Wildhoney is on a distinguished road
Default

I don't think it works, does it? It would be nice because people have posted code where it contains both PHP and HTML. If I paste such code then I usually choose the language that is most prevalent in the code.

Don't worry about that too much.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-25-2009, 05:24 PM   #9 (permalink)
The Contributor
 
Join Date: Jun 2009
Location: Seattle, WA
Posts: 76
Thanks: 1
rguy84 is on a distinguished road
Default

That is a bummer.
__________________
Ryan | Blog | Twitter
Send a message via AIM to rguy84 Send a message via MSN to rguy84 Send a message via Yahoo to rguy84 Send a message via Skype™ to rguy84
rguy84 is offline  
Reply With Quote
Old 07-17-2009, 10:13 AM   #10 (permalink)
The Contributor
 
dhaval's Avatar
 
Join Date: Jul 2009
Posts: 35
Thanks: 1
dhaval is on a distinguished road
Default

Hello,
Can we chat?
because i know that my query is beyond to solution through quick replies.
dhaval is offline  
Reply With Quote
Old 07-17-2009, 10:18 AM   #11 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,381
Thanks: 5
Salathe is on a distinguished road
Default

dhaval, stop asking "can we chat?" and start asking actual questions.

Edit: Amazingly, dhaval actually asked a question but it was in reply to this thread instead of a new one. I've since moved it to a new thread.

Last edited by Salathe : 07-17-2009 at 10:41 AM.
Salathe is offline  
Reply With Quote
Old 07-17-2009, 03:54 PM   #12 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,298
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by dhaval View Post
Hello,
Can we chat?
because i know that my query is beyond to solution through quick replies.
I've been helping people on forums for quite a few years now, you would be the first that would be true for.
__________________

Village Idiot is offline  
Reply With Quote
Old 07-17-2009, 03:56 PM   #13 (permalink)
The Addict
 
adamdecaf's Avatar
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

Quote:
Originally Posted by dhaval View Post
Hello,
Can we chat?
because i know that my query is beyond to solution through quick replies.
Your question is not unsolvable, it's that you have not posted any sample code nor explained your problem in a proper manor (understandable aka. concise).
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 02-20-2010, 11:40 AM   #14 (permalink)
The Visitor
 
Join Date: Feb 2010
Posts: 1
Thanks: 0
suneelpavu is on a distinguished road
Default

I don't think it works, does it? It would be nice because people have posted code where it contains both PHP and HTML. If I paste such code then I usually choose the language that is most prevalent in the code.

Don't worry about that too much.

Last edited by Salathe : 02-20-2010 at 04:50 PM.
suneelpavu is offline  
Reply With Quote
Old 03-23-2012, 12:26 PM   #15 (permalink)
The Visitor
 
Join Date: Mar 2012
Posts: 1
Thanks: 0
jonathan2340 is on a distinguished road
Default

Great informatiom. I just want to say you thanks for all this.
jonathan2340 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing Clean Code Village Idiot Tips & Tricks 9 05-17-2012 10:51 AM
TalkPHP IRC: Come and join us! Wildhoney News and Announcements 42 10-29-2011 03:01 PM
Tips to Improve Your Coding and Projects Village Idiot Tips & Tricks 42 01-22-2011 09:57 AM
Game: Let's Develop Something Crazy! Wildhoney The Lounge 25 05-23-2009 09:18 PM
Snipply.com - Code snippet website codyodell Show Off 27 04-13-2008 02:09 PM


All times are GMT. The time now is 03:27 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design