Advertisement

07.19.2008 at 04:58PM PDT, ID: 23579553 | Points: 250
[x]
Attachment Details

New BB Tag: [php] .. [/php]

Asked by bahadirkocaoglu in PHP Scripting Language

Tags: , , ,

Hi,

I need a custom bb tag.

Like:
[php]
<?php
echo 'test';
?>
[/php]

How can I do this?

Thanks.

I have currenty this code:Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
<?php
function parsemymessage($string) {
 
	// destroy slashes
	$string = stripslashes($string);
 
	// destroy html tags
	$string = strip_tags($string);
 
	// create smileys
	$string = str_replace(":)", "<img src=\"images/smileys/smiley.gif\" alt=\":)\" width=\"18\" height=\"18\" border=\"0\" style=\"vertical-align: middle;\" />", $string);
	$string = str_replace(":D", "<img src=\"images/smileys/cheesy.gif\" alt=\":D\" width=\"18\" height=\"18\" border=\"0\" style=\"vertical-align: middle;\" />", $string);
	$string = str_replace(";)", "<img src=\"images/smileys/wink.gif\" alt=\";)\" width=\"18\" height=\"18\" border=\"0\" style=\"vertical-align: middle;\" />", $string);
	$string = str_replace(";D", "<img src=\"images/smileys/grin.gif\" alt=\";D\" width=\"18\" height=\"18\" border=\"0\" style=\"vertical-align: middle;\" />", $string);
	$string = str_replace("???", "<img src=\"images/smileys/huh.gif\" alt=\"???\" width=\"18\" height=\"18\" border=\"0\" style=\"vertical-align: middle;\" />", $string);
	$string = str_replace(":(", "<img src=\"images/smileys/sad.gif\" alt=\":(\" width=\"18\" height=\"18\" border=\"0\" style=\"vertical-align: middle;\" />", $string);
	$string = str_replace(":o", "<img src=\"images/smileys/shocked.gif\" alt=\":o\" width=\"18\" height=\"18\" border=\"0\" style=\"vertical-align: middle;\" />", $string);
	$string = str_replace(":`(", "<img src=\"images/smileys/cry.gif\" alt=\":`(\" width=\"18\" height=\"18\" border=\"0\" style=\"vertical-align: middle;\" />", $string);
	$string = str_replace(":*", "<img src=\"images/smileys/kiss.gif\" alt=\":*\" width=\"18\" height=\"18\" border=\"0\" style=\"vertical-align: middle;\" />", $string);
	$string = str_replace(":X", "<img src=\"images/smileys/lipsrsealed.gif\" alt=\":X\" width=\"18\" height=\"18\" border=\"0\" style=\"vertical-align: middle;\" />", $string);
	$string = str_replace(":p", "<img src=\"images/smileys/tongue.gif\" alt=\":p\" width=\"18\" height=\"18\" border=\"0\" style=\"vertical-align: middle;\" />", $string);
 
	// bb codes
	$search = array(
			'/\[b\](.*?)\[\/b\]/is',
			'/\[i\](.*?)\[\/i\]/is',
			'/\[u\](.*?)\[\/u\]/is',
			'/\[s\](.*?)\[\/s\]/is',
			'/\[code\](.*?)\[\/code\]/is',
			'/\[quote\](.*?)\[\/quote\]/is',
			'/\[quote\=(.*?)\](.*?)\[\/quote\]/is',
			'/\[sub\](.*?)\[\/sub\]/is',
			'/\[sup\](.*?)\[\/sup\]/is',
			'/\[img\](.*?)\[\/img\]/is',
			'/\[url\](.*?)\[\/url\]/is',
			'/\[url\=(.*?)\](.*?)\[\/url\]/is'
	);
	$replace = array(
			'<strong>$1</strong>',
			'<em>$1</em>',
			'<u>$1</u>',
			'<s>$1</s>',
			'<div><b>Code:</b></div><div id="code">$1</div>',
			'<div><b>Quote:</b></div><div id="quote">$1</div>',
			'<div><b>Quote from: $1</b></div><div id="quote">$2</div>',
			'<sub>$1</sub>',
			'<sup>$1</sup>',
			'<img src="$1" />',
			'<a href="$1">$1</a>',
			'<a href="$1">$2</a>'
	);
	$string = preg_replace($search, $replace, $string);
 
	$search2 = array('(\[php\](.*?)\[/php\])se');
	$replace2 = array("''.highlight_string('$1', true).''");
	$string = preg_replace($search2, $replace2, $string);
 
	// \n or \r to <br>
	$string = nl2br($string);
 
	// destory spaces
	$string = trim($string);
 
	// return string
	return $string;
}
?>
[+][-]07.19.2008 at 06:10PM PDT, ID: 22044140

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.19.2008 at 11:49PM PDT, ID: 22044794

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.20.2008 at 06:49AM PDT, ID: 22045792

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.20.2008 at 07:14AM PDT, ID: 22045846

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.20.2008 at 07:53AM PDT, ID: 22045965

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.20.2008 at 07:56AM PDT, ID: 22045969

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.20.2008 at 08:18AM PDT, ID: 22046020

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.20.2008 at 08:23AM PDT, ID: 22046036

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.17.2008 at 05:26AM PST, ID: 22975252

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628