PHP: Downloading a Remote File With cURL and PHP

    $url  = '';
    $path = '/path/to/';
    $fp = fopen($path, 'w');
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_FILE, $fp);
    $data = curl_exec($ch);

PHP: Adding Parameters To A URL in PHP

PHP: Adding Parameters To A URL in PHP

Adding Parameters To A URL in PHP

This article shows how to add query parameters to a URL in a php script. It is aimed at the beginner to intermediate level PHP programmer but developers from other languages may find some useful information here. At first this seems like a simple enough task. Starting with the url as a string, just add the new parameters to the end. Yeah, that would be nice. It turns out that there are a few conditions that make the process just a bit more difficult. It’s still not a hard problem but there are enough special cases to make it interesting.

PHP: Load Time Script

PHP: Load Time

Load Time

This one is a must for developers and system admins. You need to know how long your site takes to load. Nobody sticks around waiting for a site to load anymore – there’s way too much content out there for that. Use this script to find out if your site is taking too long, and if it is, fix it. (more…)

PHP: Getting the difference between two time strings

To get the difference between two time strings use this code


function timeDiff($firstTime,$lastTime)

// convert to unix timestamps

// perform subtraction to get the difference (in seconds) between times

// return the difference
return $timeDiff;

//Usage :
echo timeDiff("2002-04-16 10:00:00","2002-03-16 18:56:32");


PHP: How to Get the Current Page URL

If you want to get the current page URL, you can use the following code:

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER&#91;"HTTPS"&#93; == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER&#91;"SERVER_PORT"&#93; != "80") {
  $pageURL .= $_SERVER&#91;"SERVER_NAME"&#93;.":".$_SERVER&#91;"SERVER_PORT"&#93;.$_SERVER&#91;"REQUEST_URI"&#93;;
 } else {
  $pageURL .= $_SERVER&#91;"SERVER_NAME"&#93;.$_SERVER&#91;"REQUEST_URI"&#93;;
 return $pageURL;
  echo curPageURL();