Best way to share PHP code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robizzle

    #1

    Best way to share PHP code

    I've been working on some php scripts that I want to release under the
    GPL and I'm looking for the best way to share the code with everyone.
    I always liked websites that had a <textfield> and put the source into
    the field, it allowed for easy copy and pasting as well as the ability
    to read the code without having to download a file, save it somewhere,
    then open it up, and lastly it preserves formatting. So on my page
    that shows source I have...

    <form>
    <br>Source of makenews.html<b r>
    <textarea cols=80 rows=30><?php $filename='make news.html.sourc e';
    if(is_readable( $filename)) if (readfile($file name) == false) echo
    'error reading '.$filename; ?></textarea>

    <br>Source of makenews.php<br >
    <textarea cols=80 rows=30><?php $filename='make news.php.source ';
    if(is_readable( $filename)) if (readfile($file name) == false) echo
    'error reading '.$filename; ?></textarea>

    ...several other documents here, you get the idea
    </form>

    Which works great, except if inside of the sourcefile somewhere there
    is a "</textarea>". When it runs into this, my page actually closes
    the text box there and the rest of the source spills out into the html
    document just as plain text would have. Is there any way I can custom
    define the escape character for an html <textarea> such that, for
    example, to terminate it I would have to say </textarea-source> or
    something similar?

    If not, or if you think you have a better way: how do you all share
    your source? I could just make links to download the actual files but
    I much prefer having all the source on the webpage.

    Sorry, I guess this is more of a html question than php but I'm also
    willing to hear any php solutions that you guys may have.

    You can see an example of my problem here:

    Notice it works fine for shownews.php and main.css, however for
    makenews.html my textarea gets closed then my div (which gives the
    light blue background) gets closed and a submit button is sitting
    outside of the source box. For makenews.php the problem is even worse,
    you can see in that link how bad it gets.

  • f3l_

    #2
    Re: Best way to share PHP code

    <xmp>

    <plaintext>



    /f3l
    Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!


    Comment

    • Justin Koivisto

      #3
      Re: Best way to share PHP code

      Robizzle wrote:[color=blue]
      > I've been working on some php scripts that I want to release under the
      > GPL and I'm looking for the best way to share the code with everyone.
      > I always liked websites that had a <textfield> and put the source into
      > the field, it allowed for easy copy and pasting as well as the ability
      > to read the code without having to download a file, save it somewhere,
      > then open it up, and lastly it preserves formatting. So on my page
      > that shows source I have...
      >
      > <form>
      > <br>Source of makenews.html<b r>
      > <textarea cols=80 rows=30><?php $filename='make news.html.sourc e';
      > if(is_readable( $filename)) if (readfile($file name) == false) echo
      > 'error reading '.$filename; ?></textarea>
      >
      > <br>Source of makenews.php<br >
      > <textarea cols=80 rows=30><?php $filename='make news.php.source ';
      > if(is_readable( $filename)) if (readfile($file name) == false) echo
      > 'error reading '.$filename; ?></textarea>
      >
      > ...several other documents here, you get the idea
      > </form>
      >
      > Which works great, except if inside of the sourcefile somewhere there
      > is a "</textarea>". When it runs into this, my page actually closes
      > the text box there and the rest of the source spills out into the html
      > document just as plain text would have. Is there any way I can custom
      > define the escape character for an html <textarea> such that, for
      > example, to terminate it I would have to say </textarea-source> or
      > something similar?
      >
      > If not, or if you think you have a better way: how do you all share
      > your source? I could just make links to download the actual files but
      > I much prefer having all the source on the webpage.
      >
      > Sorry, I guess this is more of a html question than php but I'm also
      > willing to hear any php solutions that you guys may have.
      >
      > You can see an example of my problem here:
      > http://www.cse.msu.edu/~meyerro3/pro...ces.broken.php
      > Notice it works fine for shownews.php and main.css, however for
      > makenews.html my textarea gets closed then my div (which gives the
      > light blue background) gets closed and a submit button is sitting
      > outside of the source box. For makenews.php the problem is even worse,
      > you can see in that link how bad it gets.[/color]

      On my site, I use this:
      <div class="example" >
      <?php highlight_file( 'filename.php') ; ?>
      </div>

      Then I use CSS to stylize the rest.

      You could also do something along the lines of:

      <textarea><?p hp echo htmlentities(fi le_get_contents ('filename.php' ))
      ?></textarea>

      --
      Justin Koivisto, ZCE - justin@koivi.co m

      Comment

      Working...