Welcome To Snipplr
Everyone's Recent PHP Snippets Tagged function
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
This makes template code that applies to children of a particular page much more readable, especially if you can use a page path instead of an ID: `if ( is_child_of( 'topic/subtopic' ) ) :`.
1
919
posted 15 years ago by cyberhobo
very useful function that allows you to redirect to the user to a given location
1
959
posted 15 years ago by daveismyname
closes opened tags in text piece.
original code slightly modified to supress PHP warnings
NOTE: need to fix the order of closing tags to get standards compliance
0
841
posted 15 years ago by kossmoss
Returns last word of a string (words separated by blanks). if string does not have any blanks, it will return the whole string.
1
937
posted 15 years ago by fischkopp
Secure, Advanced, Better, Faster... function for remove/strip tags(Anti-XSS).
2
1268
posted 16 years ago by YPY
This will count sentences that end in . or ? or ! and have a space after them.
1
2152
posted 16 years ago by evanwalsh
A small function I made to chmod directories and files recursively, with different permissions.
2
1250
posted 16 years ago by Tenzer
Add this template before functions in a library, in order to give a good description of what it is and what it does. Replace all in < and > with your values.
2
1022
posted 17 years ago by engel
Pass a user-inputted variable to this function in order to prevent SQL injection. Example:
mysql_query("INSERT INTO table VALUES('" . sql_sanitize($_POST["variable") . "')");
Instead of:
mysql_query("INSERT INTO table VALUES('" . $_POST["var...
34
5753
posted 17 years ago by engel
This PHP4 function will increment a given string by a given interval. This might be useful when a string has to be unique. An optional array with "forbidden" return values may be passed.
Usage:
2
907
posted 17 years ago by drwitt
This function first checks to see if PHP is set to automagically quote stuff. If it is, we first strip pre-quoted stuff, then (assuming our text isn't numeric), we properly quote everything.
A good bit of room for improvement here, but at the very l...
1
792
posted 18 years ago by sorehead