Php cheat sheet


Published on

Published in: Education
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Php cheat sheet

  1. 1. Arrays Regexarray_intersect ereg array_merge eregi array_pop ^ Start of string Y 4 digit year 2005 ereg_replace array_push $ End of string y 2 digit year 05 eregi_replace array_reverse . F split Any single character Long month January array_walk spliti count (a|b) a or b M Short month Jan preg_match in_array (...) Group section m Month (leading zeros) 01 to 12 preg_match_all [abc] Item in range (a or b or c) n Month 1 to 12 preg_replaceDate and Time [^abc] D preg_split Not in range (not a or b or c) Short day name Mon date mktime s White space l Long day name Monday Sessions strtotime a? Zero or one of a d Day (leading zeros) 01 to 31 session_destroy time a* Zero or more of a j Day 1 to 31 session_id a+ One or more of a session_start Filesystem clearstatcache a{3} Exactly 3 of a h 12 Hour (leading zeros) 01 to 12 Strings copy a{3,} 3 or more of a g 12 Hour 1 to 12 addslashes fclose a{3,6} Between 3 and 6 of a H 24 Hour (leading zeros) 00 to 23 crypt fgets G echo Escape character 24 Hour 0 to 23 file explode filemtime i Minutes (leading zeros) 00 to 59 implode filesize [:punct:] Any punctuation symbol s Seconds (leading zeros) 00 to 59 md5 file_exists [:space:] Any space character nl2br fopen [:blank:] w sprintf Space or tab Day of week 1 0 to 6 fread strip_tags fwrite z Day of year 0 to 365 stripslashes is_dir W Week of year 2 1 to 53 stristr is_file t Days in month 28 to 31 strpos readfile strrev i Case-insensitive strstr Headers s Period matches newline a am or pm strtolower header m ^ and $ match lines A AM or PM strtoupper headers_sent U Ungreedy matching B Swatch Internet Time 000 to 999 str_replace setcookie S substr e Evaluate replacement Ordinal Suffix st, nd, td, th trim Mail x Pattern over several lines mail T Timezone of machine GMT URLs Z Timezone offset (seconds) rawurldecode Numbers O rawurlencode Difference to GMT (hours) +0200 ceil urldecode floor I Daylight savings 1 or 0 urlencode array_push ( array, element )number_format L Leap year 1 or 0 round in_array ( needle, haystack ) Variables explode ( separator, string ) empty U Seconds since Epoch 3Miscellaneous split ( pattern, string ) is_array define c ISO 8601 (PHP 5) is_int preg_split ( pattern, string ) eval r RFC 2822 is_null exit ereg ( pattern, string ) is_numeric strpos ( haystack, needle ) 1. date("w"): 0 is Sunday, 6 is Saturday. is_object Network str_replace ( search, replace, string ) isset fsockopen serialize 2. Week that overlaps two years belongs to unserialize PHP Options year that contains most days of that ini_get week. Hence week number for 1st January SuperGlobals ini_restore of a given year can return 53rd week if $_ENV ini_set r Read $_GET week belongs to previous year. phpinfo r+ Read and write, prepend $_POST date("W", mktime(0, 0, 0, 12, 28, $year)) $_COOKIE w Write, truncate Execution always gives correct number of weeks in $_SESSION w+ Read and write, truncate exec $year. $_SERVER a Write, append $_FILES a+ Read and write, append $_REQUEST 3. The Epoch was the 1st January 1970. $GLOBALS Available free from