Re: 'Code Snippets' you couldn't live without

From: Date: Wed, 03 Nov 2004 20:10:28 +0000
Subject: Re: 'Code Snippets' you couldn't live without
Groups: php.general 
Request: Send a blank email to php-general+get-201082@lists.php.net to get a copy of this message
Murray @ PlanetThoughtful wrote:
Hi All, I'm curious to know what other members of the list think of as the code snippets they couldn't live without when working on a PHP project. IE, the kind of re-usable bits and pieces that make your life a lot easier. For myself, I have an include file in which I define 'shorthand' functions for functions etc I use on a regular basis. Eg: function asl($val){ return addslashes($val); } function mfr(&$rset){ mysql_free_result($rset); } ...and so on. Just thought it would be interesting to see what others do to make programming more bearable.
Probably the custom one I use the most is for getting data... function selectData ( $sql ) { if ( ! $_SESSION['mysql']['status'] ) { dbconn(); } if ( $result = @mysql_query ( $sql ) ) { $return = array(); while ( $row = @mysql_fetch_array ( $result ) ) { array_push ( $return, $row ); } @mysql_free_result ( $result ); return $return; } else { $msg = "The query could not be executed."; raiseError ( $msg, 0, 1 ); return false; } } -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 john@kegworks.com

« previous php.general (#201082) next »