It was a bit of a trick to find the DateInterval spec hidden away in the constructor doco, not the DateInterval class doco.
Designator | Description |
---|---|
Y | years |
M | months |
D | days |
W | weeks |
H | hours |
M | minutes |
S | seconds |
It was a bit of a trick to find the DateInterval spec hidden away in the constructor doco, not the DateInterval class doco.
Designator | Description |
---|---|
Y | years |
M | months |
D | days |
W | weeks |
H | hours |
M | minutes |
S | seconds |
Used call_user_func_array today, in Slib…
Reading about define() vs const…
I needed to know my options for htmlentities character encoding support today. The PHP documentation had everything I needed to know. I ended up adding these constants to my code:
const UTF8_ENCODING = 'UTF-8'; const ASCII_ENCODING = 'ISO-8859-1';
Using PHP Output Buffering Control…
Today I queried the $_SERVER[ ‘SERVER_PROTOCOL’ ] value in PHP to determine the HTTP version used by the request.
All you need to know is on the date documentation…
Today I needed to figure out how to read some data from a URL that required HTTP Basic Auth. The solution was pretty simple, use file_get_contents and pass in a configured stream context. I found the following code on the stream_context_create documentation:
$cred = sprintf( 'Authorization: Basic %s', base64_encode( 'username:password' ) ); $opts = array( 'http' => array( 'method' => 'GET', 'header' => $cred ) ); $ctx = stream_context_create( $opts ); $data = file_get_contents( $url, false, $ctx );
Easy-peasy!
Used PHP’s urlencode today…