Best way to share PHP code

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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...

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

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

        ...several other documents here, you get the idea

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.

Re: Best way to share PHP code




Re: Best way to share PHP code

Robizzle wrote:
Quoted text here. Click to load it

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

Then I use CSS to stylize the rest.

You could also do something along the lines of:

<textarea><?php echo htmlentities(file_get_contents('filename.php'))  

Justin Koivisto, ZCE -

Site Timeline