View Full Version : Guidelines for posting a PHP snippet

Nov 5th, 2005, 08:51 PM
Use this forum to post a useful PHP snippet, whether a useful function or a small completed PHP script. In general the code must be small enough so that you can post its entire source here. Do not simply post a link to an external PHP site or product page (spam). This forum is used to illustrate PHP techniques and to provide easily digestible PHP codes, not the classifieds to advertise your PHP site or product. The later will be deleted without warning.

Extended Rules:
1) Snippets need to be tested & working
2) Please check the PHP manual first to ensure you are not duplicating an internal PHP function (unless your version adds something missing from the original)
3) If your code is potentially insecure due to editing for brevity please state that fact and point out possible problems. (if nothing else to stop all the `this is insecure` followups)
4) Snippets which are deemed to be essentially pointless or not relevant will be removed , its nothing personal just quality control.
5) Whilst we do not want to dictate coding standards please code for register_globals=off
6) If your snippet requires a certain version of PHP , especially >=5.0 please state that fact.

As a general rule (especially relating to point 4), your PHP snippet should add something that the PHP language cannot nativley do, or use built in PHP functions in such a way that you have a useful snippet of code. Snippets like:

$variable = rand(0,10);
// $variable is now a random number between 0 and 10

will not qualify to be kept in the forum, as they dont add anything, they just use PHP internal functions in a very simple way. As stated, its nothing personal, just quality control.