473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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<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
</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.

Oct 21 '05 #1
2 2465
<xmp>

<plaintext>

/f3l
http://www.geocities.com/kyoosho/

Oct 21 '05 #2
Robizzle wrote:
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<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
</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.


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><?php echo htmlentities(file_get_contents('filename.php'))
?></textarea>

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Oct 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ares Lagae | last post by:
Suppose one is writing a library behavior the classes A1, A2 and A3, which share some common behavior. Some applications will only use one of the classes, while other applications will use all of...
3
by: kyle.tk | last post by:
So I have a central list of python objects that I want to be able to share between different process that are possibly on different computers on the network. Some of the processes will add objects...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
1
by: Chua Wen Ching | last post by:
Hi there, I had a scenario here. I had many tonnes of C codes in my office. Each C codes are used in low level stuff. Like connecting to smart card readers or even the OS itself. I was being...
5
by: Schoo | last post by:
I have some program constants that I need to set and I thought it would be best to set them all up in a central location so that I can change them quickly when we go from development to production....
6
by: tendim | last post by:
G'day group. Currently our organization us using VB6 based applications, and I am trying to push forward and migrate some of the smaller things to VB.NET, eventually migrating all applications...
13
by: frk.won | last post by:
I am interested in learning how to use the VS 2005 code snippets. However, I wish to know what are the best ways to source control the code snippets? Are there any source safe/subversion...
6
by: Jack | last post by:
I have a set of functions to wrap a library. For example, mylib_init() mylib_func() mylib_exit() or handle = mylib_init() mylib_func(handle)
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.