Php: Difference between revisions

From Adam Colton
Jump to navigation Jump to search
No edit summary
Line 7: Line 7:
   cat /var/log/apache2/error.log
   cat /var/log/apache2/error.log


== Dates ==
== Dates and Times==
   date('Y-m-d H:i:s') //mysql datetime
   date('Y-m-d H:i:s') //mysql datetime
   date('Y-m-d') //mysql date
   date('Y-m-d') //mysql date
  time() returns current unix time


== Arrays ==
== Arrays ==

Revision as of 17:19, 18 February 2016

Misc.

  • count($arr) : returns array length
  • join($glue, $arr)
  • is_null($foo)

Error Log

 cat /var/log/apache2/error.log

Dates and Times

 date('Y-m-d H:i:s') //mysql datetime
 date('Y-m-d') //mysql date
 time() returns current unix time

Arrays

 array_key_exists(key,array);

JSON

 json_decode($str, true);
 json_encode($obj);

The true makes it associative.

Files

 readfile($filename);

Ouputs the file to stdOut.

 file_put_contents($filename, $str);

Write string to file.