This language have bunch of methods, do you guys any favorites? share it for me, and what is it for? thanx
methods are functions contained inside classes / objects and functions are procedural functions. I'm not sure I have a favourite function or class, there are millions, too many :S
I'm sure that there's no way you can memorize all millions of them right? so probably there are some of them that you use most? :-/
well I wouldn't like to write a big list, but if I'm writing an application I can normally think of two or three ways of doing whatever I'm trying to do. I suppose I can think of a list of preferences for programming, I'll use substr over preg_match|replace mysql_connect over mysql_pconnect preg_match over ereg split over explode arrays over strings classes over procedural fopen|read|write|close over file_get|put_contents ( not because of speed but control over the process ) curl over sockets fsockopen over sockets windows program over php script - oh yes !! mysql_fetch_assoc over mysql_result you find when you have been doing it for a while most common functions are at the front of your brain
isset() // if you're unsure of something instanceof // not a function, but it makes the code look cooler
Well not a native PHP function but people seem to always think is_int checks for integer on post values and thing of that nature. So here is a simple isInt function that can do integer checks on php strings (post,get,cookie ect.) function isInt($value) { return (is_numeric($value) ? intval($value) == $value : false); } PHP: