Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 26

Thread: Showing php in bbcode

  1. #11
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    srry, but this driving me up the wall.

    you know how you can use these tags

    php] /php]

    I want to be able to use them in my forum, but no one has an example or tutorial on how to show me...

    i want to use php bbcode tags in my forum(I already have bbcode I just need a example)

    uh sorry for being mean...
    Hey new design new look, goto xudas for personal webdsign help.. (:

  2. #12
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Yeah... then use PHP in the code provided in the link in post 2. As tech_support posted, he added image tags himself. Just copy the format from the other ones.
    That's it.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #13
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile

    I have tried to make my own php tags but the php tags are different from the img tags, for example...

    img tags look like this
    Code:
    [img=$text}[/img}
    and in php it would look like this
    Code:
    <img src=$text>
    But as in php, you would use these,
    Code:
    [php} <?php code here ?> [/php}
    But what is it translated into?
    like how or what is the php code to show php?
    understand, no one has this in the bbcodes they have the simple stuff, like b, i, strike, u, and imgs, but what about php, can someone show me how to put php tags into bbcode cuase I can't figure it out,...

    if no one can, then dont worry about it,

    and post 2 does not have the php tags in it cuase I have already looked at it

    and just to let you guys know my bbcode is below, to show you, i think...
    PHP Code:
    <?php
       $message 
    str_replace("[b]""<b>"$message);
       
    $message str_replace("[/b]""</b>"$message);

       
    $message str_replace("[i]""<i>"$message);
       
    $message str_replace("[/i]""</i>"$message);

       
    $message str_replace("[code]""<div style=\"border: solid 1px orange; padding:20px; margin: 20px\"><code>"$message);
       
    $message str_replace("[/code]""</code></div>"$message);

       
    $message str_replace("[u]""<u>"$message);
       
    $message str_replace("[/u]""</u>"$message);

       
    $message str_replace("[s]""<s>"$message);
       
    $message str_replace("[/s]""</s>"$message);

       
    $message str_replace("[color=blue]""<span style=\"color: blue\">"$message);
       
    $message str_replace("[/color]""</span>"$message);

       
    $message str_replace("[color=red]""<span style=\"color: red\">"$message);
       
    $message str_replace("[/color]""</span>"$message);

       
    $message str_replace("[color=green]""<span style=\"color: green\">"$message);
       
    $message str_replace("[/color]""</span>"$message);

       
    $message str_replace("[color=yellow]""<span style=\"color: yellow\">"$message);
       
    $message str_replace("[/color]""</span>"$message);

       
    $message str_replace("[color=gray]""<span style=\"color: gray\">"$message);
       
    $message str_replace("[/color]""</span>"$message);

       
    $message str_replace("[color=pink]""<span style=\"color: pink\">"$message);
       
    $message str_replace("[/color]""</span>"$message);


    /* here is where i get messed up and want the php tags */
       
    $message str_replace("[php}""<php>"$message);
       
    $message str_replace("[/php}""</php>"$message);
    /* here is where i get messed up and want the php tags */


       
    $message=eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]","<a href=\"http://www.\\1\" target=_blank>\\1</a>",$message);
       
    $message=eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"http://www.\\1\" target=_blank>\\1</a>",$message);
       
    $message=eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>\\1</a>",$message);

       
    $message=eregi_replace("\\[email\\]([^\\[]*)\\[/email\\]","<a href=\"mailto:\\1\">\\1</a>",$message);






       
    $message str_replace('[img]''<img src="'$message);
       
    $message str_replace('[/img]''" border=0>'$message);

       
    $message str_replace(":)""<img src=\"http://www.xudas.com/forum/forum/images/smile2.gif\"><BR>"$message);

       
    $message str_replace(":(""<img src=\"http://www.xudas.com/forum/forum/images/sad.gif\"><BR>"$message);

       
    $message str_replace(":\$""<img src=\"http://www.xudas.com/forum/forum/images/confoosed.gif\"><BR>"$message);

    ?>
    Oh and whereever you see this( "}" ) its supposed to be this ( "]"). code gets mess up..
    Hey new design new look, goto xudas for personal webdsign help.. (:

  4. #14
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    [php]<? php; ?>[/php]
    Becomes:
    highlight_string('<? php; ?>');

    ie, [php]$code[/php]
    highlight_string($php);

    And you get--
    PHP Code:
    <?php php?>
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #15
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Finally!!!! THANKYOU SO MUCH!!!

    I didn't know how or what to do...
    I thanked you
    Hey new design new look, goto xudas for personal webdsign help.. (:

  6. #16
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Actually i can't get it to work, is there a possible way you could post it in this format..
    PHP Code:
       $message = str_replace("[php}", "<?php php;{ ?>", $message); 
       $message = str_replace("[/php}", "<?php ?>", $message);
    Thats something I tried above and I have tried other solutions, is there a way you could show me a example using that above?

    and its the same with other bbcode as in message is the text for the forums
    like
    Code:
       $message=bbcode($message);
    I hope you understand..
    Hey new design new look, goto xudas for personal webdsign help.. (:

  7. #17
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It isn't just replacing the start/end with a tag. you need to run it through the function.

    Basically--

    Code:
    while (strpos($c,'[php]')!==FALSE&&strpos($c,'[/php]',strpos($c,'[php]'))!==FALSE) {$c = substr($c,0,strpos($c,'[php]')).highlight_string(substr($c,strpos($c,strpos($c,'[php]'),strpos($c,'[/php]',strpos($c,'[php]'))))).substr($c,strpos($c,'[/php]',strpos($c,'[php]')));}
    Last edited by djr33; 09-24-2007 at 09:17 PM.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #18
    Join Date
    Oct 2005
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    ok ty so much im gonna try this!!! TY

    oh is
    $c where $message is supposed to be?
    Hey new design new look, goto xudas for personal webdsign help.. (:

  9. #19
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I just used $c for code since I didn't want to type a long variable name in that complex statement.


    This is actually much harder than I thought it would be.

    I've been testing it and the bugs are worked out, but there is a major problem.

    Here's the code I have now:
    Code:
    while (strpos($c,'[php]')!==FALSE&&strpos($c,'[/php]',strpos($c,'[php]'))!==FALSE) { $c = substr($c,0,5+strpos($c,'[php]')).highlight_string(substr($c,strpos($c,5+strpos($c,'[php]'),6+strpos($c,'[/php]',strpos($c,'[php]')))),TRUE).substr($c,6+strpos($c,'[/php]',strpos($c,'[php]')));}
    The problem, though, is the function highlight_string().

    http://www.php.net/manual/en/functio...ght-string.php

    Apparently it outputs rather than returning the highlighted code. A second parameter of TRUE is apparently supposed to make it return the code instead.
    I set that... but... it doesn't seem to work.

    Anyone used this before successfully?

    Without the TRUE value, it outputs. With the TRUE value, I get a big memory allocation error--
    Code:
    Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 8855008 bytes) in /home/livechat/public_html/sys/test.php
    Ideas?


    Aside from that, though, the code works just fine.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #20
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    I messed with it briefly before, but don't remember what I did exactly. I do remember; though, that I had to use the output buffer to get it to work right. That way everything parsed wrote to the ob, then I was able to output everything at the end of the script execution.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

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
  •