User:Tisane/My first PHP script

<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */

// create a new cURL resource $ch = curl_init; $useragent="User:Tisane (http://www.mediawiki.org/wiki/User:Tisane) working toward some mediawiki enhancements"; $article='Libertarianism'; $url='http://en.wikipedia.org/w/index.php?title=Special:Export&pages='.$article.'&offset=1&limit=5&action=submit'; $filename=$article; $fp = fopen("example_homepage.txt", "w");

// set URL and other appropriate options $options = array(CURLOPT_URL => $url,                CURLOPT_HEADER => false,                 CURLOPT_POST => true,                 CURLOPT_USERAGENT => $useragent,                 CURLOPT_FILE => $fp                );

curl_setopt_array($ch, $options);

// grab URL and pass it to the browser curl_exec($ch);

// close cURL resource, and free up system resources curl_close($ch); ?>