sudo apt-get install php5 php5-mysql php5-xsl php-apc php5-xdebug location of php.ini: /etc/php5/cli/ /etc/php5/apache/ errors: display_errors = On error_reporting = E_ALL or others error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); memory: ini_set("memory_limit","32M"); for windows and apache: in httpd.conf to end of LoadModule list: LoadModule php5_module "<+path to php5apache2_2.dll in php installation folder+>" does not exist in non-thread-safe version to end of httpd.conf: PHPIniDir "path to php.ini dir" after AddType lines AddType application/x-httpd-php .php DirectoryIndex index.php index.html if mysqli missing: comment the ;extend=php_mysqli.dll restart, uncomment, restart transliteration: iconv library needs utf-8 encoding php tags: omit closing tags: to avoid blanks zend and drupal standard http://stackoverflow.com/questions/3219383/why-do-some-scripts-omit-the-closing-php-tag operators: modulo: % string/array operations: explode (delimiter, string) formatted string: sprintf(); remove last element: array_pop() remove first element: array_shift() array keys: array_keys for an object: get_object_vars foreach: foreach (array as value) foreach (array as value => key) replace: str_replace(search, replace, subject) preg_replace(pattern, replacement, subject) see [[regexp]] use \0 usw (escaped to \\0) replace characters: strtr($str, "éàè", "eae"); convert urls to links: $str = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "\\0", $str); my conventions: define(BASE_PATH,'/web/path/to/main/dir'); execute: exec(cmd, output_arr, return_status) string functions: find first occurrence: strpos() substr(str,start,length) headers: header("Content-type: text/javascript"); text/css content-types: mime-types image/gif, image/jpeg, text/plain, text/richtext, application/postscript, multipart Content-Disponition: attachment; filename=fname.pdf redirect: header("Location: http://www.example.com/"); command line arguments: $argv function arguments as array: func_get_args() get directory from path: dirname mysql: $result = mysql_query(...); if (!$result) { ... mysql_error(); } while ($row = mysql_fetch_assoc($result)) { } mysql_free_result($result); mysql_connect(server, uname, password, link); mysql_select_db mysql_close() mysql_fetch_assoc mysql_query mysql_error arrays: in_array(element, array) sort: sort(), rsort() keep keys: asort(), arsort() files: file_put_contents(file, string[, flags]) FILE_APPEND overwrite: fopen(file,'w'); fwrite(fd,string); append: fopen(file,'a'); geshi: import geshi.php new GeSHi(); set_language set_source tab width: set_header_type(GESHI_HEADER_DIV) set_tab_width parse_code exec: use escapeshellarg or escapeshellcmd date/time: now's timestamp: time() create a timestamp/date: mktime(hour, minute, secnd, month, day, year) parse a time/date: strtotime(time) time formats 12 hour: hh[ \t]meridian hh[.:]MM[ \t]?meridian hh[.:]MM[ \t]?meridian hh[.:]MM[.:]II[ \t]?[0-9]+meridian 23 hour: T?HH[.:]MM T?HHMM T?HH[.:]MM[.:]II T?HHMMII T?HH[.:]MM[.:]II[ \t]?(tzcorrection|tz) T?HH[.:]MM[.:]IIfrac tz|tzcorrection date formats many iso: YYMMDD YY/MM/DD yy-MM-DD [+-]?YY-MM-DD information: getdate(timestamp) seconds: 0-59 minutes: 0-59 hours: 0-23 mday: 1-31 wday: 0(sunday)-6 mon: 1-12 year: 2001 yday: 0-365 weekday: Monday month: January 0: timestamp formatted: date(format, timestamp) day of month: d short text of day of week: D day of month without 0: j long text of day of week: l numeric day of week: N st, nd, rd, th: S (use jS) numeric day of week (sunday: 0): w day of year (start: 0): z week of year: W text of month: F numeric month: m short text of month: M numeric month without 0: n days in month: t leap year (1 or 0): L year number (depending on whole week number): o year number: Y two digit year number: y am, pm: a AM, PM: A internet time: B hour (01-12): g hour (00-23): H minutes (00-59): s microseconds: u timezone: e daylight saving time: I diff with GMT (+0200): O diff with GMT (+02:00): P timezone abbr: T timezone offset in secs: Z ISO 6601 (2004-02-12T15:19:21+00:00): c RFC 2822 formatted date (Thu, 21 Dec 2000 16:01:07 +0200): r time(): U read ini files: parse_ini_file(file, [process sections?]) [local] [remote] and in .htaccess SetEnv ENVIRONMENT local development phases: development, staging, production pecl: http-request and so on install php5-dev libcurl3 libcurl-openssl-dev first sudo pecl install pecl_http variables: get defined variables: get_defined_vars()