Categories
PHP Ubuntu

Install PHPunit on Ubuntu

sudo pear upgrade PEAR

pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit

Categories
PHP Web site

PHP vs. PYTHON vs. RUBY

Categories
PHP

How to post data in PHP using file_get_contents?

$postdata = http_build_query(
    array(
        'var1' => 'some content',
        'var2' => 'doh'
    )
);

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);

$context  = stream_context_create($opts);

$result = file_get_contents('http://example.com/submit.php', false, $context);