Tag Archives: Context


Stream_context_create — Creates a stream context.

Creates and returns a stream context with any options supplied in options preset.

 $opts = array(
 'header'=>"Accept-language: en\r\n" .
 "Cookie: foo=bar\r\n"

$context = stream_context_create($opts);
 $fp = fopen('http://www.phpcodez.com', 'r', false, $context);

REST Context Switching

o Refers to the act of providing different output based on criteria from the request

o The process inspects the http request headers and/or the request uri, and varies the response appropriately

o Commonly used for:

 providing different output for requests originated via xmlhttprequest

 providing different output based on accept http headers (ex: rest endpoints)

 providing alternate layouts/content based on browser detection