FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


+BBCode [php]...[/php]





Aredon
Most forums have a PHP bbcode tag in addition to a CODE tag. Mind adding a PHP bbcode tag?
If my logic is correct, it uses the same coding as the CODE tag with the small difference of the usage of the highlight_string function to color it.

Then just change the wording "Code:" to "Php:"
Code:
...


and update the BBCode Guide
LukeakaDanish
Its not that I don't think its a good idea...

However is there even one good reason bondings should use up some of his precious frihost time coding this?
MrBlueSky
It certainly makes PHP code in posts more readable.
LukeakaDanish
MrBlueSky wrote:
It certainly makes PHP code in posts more readable.


Well...its entirely readable inside [code] tags already...and it shouldn't be necessary to mark code as php...that is generally visible both from the context but also from the code itself...
m-productions
I always wished frihost has the [php] tags, this makes it very much more readable and friendly. As it highlights information that is needed. Also, it will look the same as in a php editor, which might make it easier for a new person to understand, I really wish this would be added.. i really think it is needed. the [code] just is not good enough.
MrBlueSky
Yes, but what I meant was: when making the posted PHP code being highlighted makes the code much more readable. And sinds PHP has a build-in function to syntax-highlight PHP it doesn't have to be difficult to add this feature.

Compare this:

Code:

define('CHAR_WHITESPACE', 1);
define('CHAR_UNCLASSIFIED', 2);

function characterType($input) {
   if(strlen($input) > 1) {
      $input = $input[0];
   }
     
   switch($input) {
      case ' ':
      case '\t':
      case '\n':
      case '\r': {
         return CHAR_WHITESPACE;
      } break;
     
      default: {
         return CHAR_UNCLASSIFIED;
      }
   }
}

function stripWhitespace($string, $beg = true, $trail = true) {
   $nString = $string;
        $subLength = strlen($string);
     
   $brPos = 0;
   $brPosE = 0;
     
   if($beg === true) {
      for($i = 0; $i < ($subLength); $i++) {
         if($this->characterType($string[$i]) != CHAR_WHITESPACE) {
            $brPos = $i;
            break;               
         }
      }
   }
     
   if($trail === true) {
      for($i = ($subLength-1); $i >= 0; $i--) {
         if($this->characterType($string[$i]) != CHAR_WHITESPACE) {
            $brPosE = $i;
            break;
         }
      }
         
      $brPosE = ($brPosE + 1) - $brPos;
   } else {
      $brPosE = $subLength - $brPos;
   }
     
   $nString = substr($string, $brPos, $brPosE);
     
   return $nString;
}



Quote:

To this:

define('CHAR_WHITESPACE', 1);
define('CHAR_UNCLASSIFIED', 2);

function characterType($input) {
if(strlen($input) > 1) {
$input = $input[0];
}

switch($input) {
case ' ':
case '\t':
case '\n':
case '\r': {
return CHAR_WHITESPACE;
} break;

default: {
return CHAR_UNCLASSIFIED;
}
}
}

function stripWhitespace($string, $beg = true, $trail = true) {
$nString = $string;
$subLength = strlen($string);

$brPos = 0;
$brPosE = 0;

if($beg === true) {
for($i = 0; $i < ($subLength); $i++) {
if($this->characterType($string[$i]) != CHAR_WHITESPACE) {
$brPos = $i;
break;
}
}
}

if($trail === true) {
for($i = ($subLength-1); $i >= 0; $i--) {
if($this->characterType($string[$i]) != CHAR_WHITESPACE) {
$brPosE = $i;
break;
}
}

$brPosE = ($brPosE + 1) - $brPos;
} else {
$brPosE = $subLength - $brPos;
}

$nString = substr($string, $brPos, $brPosE);

return $nString;
}
LukeakaDanish
ok...NOW i get you...and now I think its a really good idea Smile
garionw
But I overheard HTML and javascript saying that they were going to be depressed if PHP got special treatment in the forums (I think I even heard javascript say he was going to leave frihost if that happened)
hack_man_
garionw wrote:
But I overheard HTML and javascript saying that they were going to be depressed if PHP got special treatment in the forums (I think I even heard javascript say he was going to leave frihost if that happened)

Yeah! We would have to give all the other programming languages that have forum categories their own exclusive code tag, and then we would end up with a full uprising as the other languages that are on the servers but not on the forums get annoyed. I think that this a great idea, it makes everything a lot easier to read...
snowboardalliance
garionw wrote:
But I overheard HTML and javascript saying that they were going to be depressed if PHP got special treatment in the forums (I think I even heard javascript say he was going to leave frihost if that happened)


PHP can do the highlighting already (it's a built in function) so it would be the easiest to add.
ninjakannon
snowboardalliance wrote:
garionw wrote:
But I overheard HTML and javascript saying that they were going to be depressed if PHP got special treatment in the forums (I think I even heard javascript say he was going to leave frihost if that happened)


PHP can do the highlighting already (it's a built in function) so it would be the easiest to add.

Furthermore, I think php code is included more in posts than either html or JavaScript.

This idea is good, but no more than 'good' in my opinion. Php is not used my a vast proportion of the members at FriHost and indeed code segments are found in few of the forums here. A php tag would just lie unused by the majority of members. Although I do quite like idea, I just don't think it's needed enough.
m-productions
No it woudlnt, actully, you sould use the php tag for anything, for example, over at flashkit, a lot of people use the php code for ActionScript as well, same for other languages.. its just, overall looks nicer than code, and its easy to add.
ninjakannon
m-productions wrote:
No it woudlnt, actully, you sould use the php tag for anything, for example, over at flashkit, a lot of people use the php code for ActionScript as well, same for other languages.. its just, overall looks nicer than code, and its easy to add.

You're right, they do! And yes it can be used for any programming language as it becomes easier to read and spot mistakes that way.

But, using Flashkit as an example, I've really only seen this feature on specialised forums; those that are dedicated to php, another language or just programming in general. Perhaps the Php button (along with the Quote, Code and other buttons) should only appear in certain forums and be hidden in others? Of course, the tag would still be work if used, but there would be no need for a button - that's all.
m-productions
huh? its in all the forums, in fact, when i help people out in either the flash 8 or flash newbie section, i use the php code, and one of the mods there.. (cancerinform) something like that, also used php code in every forum for flash


basicly, it still highlights the basics in anything, such is if, else.... blah blah.
ninjakannon
m-productions wrote:
huh? its in all the forums, in fact, when i help people out in either the flash 8 or flash newbie section, i use the php code, and one of the mods there.. (cancerinform) something like that, also used php code in every forum for flash


basicly, it still highlights the basics in anything, such is if, else.... blah blah.

Opps! I meant specialised boards and not specialised forums, Sorry! It is in all the forums on Flashkit, I'm not sure what you mean by 'cancerinform' though. Hmm... I haven't been to Flashkit for absolutely aaaaaages; I must go sometime soon and see who needs some help. The trouble is that the board is so popular now that usually everyone's questions are already answered. Actually, I would hardly call that trouble. Heh, I've gone wildly off-topic here!
Related topics
Reply to topic    Frihost Forum Index -> General -> Suggestions

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.