Post data using file_get_contents()

Sets context to make post request when using file_get_contents().

php
fork add to bundle source
function post_fgc($url, $data) { $options = ['http' => [ 'method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => http_build_query($data) ] ]; $context = stream_context_create($options); return file_get_contents($url, false, $context); }

usage

load_function('post_fgc'); echo post_fgc('https://example.com/signup', ['name' => 'John']); // Will post data to example.com/signup
← how to use this in app?
create log ...inout