PHP Create directory

Creates a directory in the server’s file system.

function makeDirectory($path) {
  if (!is_dir($path)) {
    $oldumask = umask(0);
    mkdir($path, 0777);
    umask($oldumask);
    chmod($path, 0777); // octal; correct value of mode
  }
}

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(No Ratings Yet)
 Loading ...

PHP Delete file

Delete a file in the file system. Note that this file system we’re talking about is the server’s file system. PHP nor other web-based programming language deletes a file system on the client’s side.

function deleteFile($filename) {
  $do = unlink($filename);

  if ($do==”1″) {
    echo “The file was deleted successfully.”;
  } else {
    echo “There was an error trying to delete the file.”;
  }
}

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(1 votes, average: 5.00 out of 5)
 Loading ...

PHP Get difference between 2 dates

This code gets the date difference manually, specifying a date value.

$digest_date = “2009-12-25″;
$date_diff = abs(strtotime(date(’y-m-d’))-strtotime($digest_date)) / 86400;

and another version in a method if you want to keep on reusing this code.

function dateDiff($dformat, $endDate, $beginDate) {
  $date_parts1=explode($dformat, $beginDate);
  $date_parts2=explode($dformat, $endDate);
  $start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
  $end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
  return $end_date - $start_date;
}

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(No Ratings Yet)
 Loading ...

Mac Shortcuts


Transition from Windows to Mac OS is pretty hard. It wasn’t easy for me at first considering I’ve been used to using Windows for more than a decade now. Both do have standard keyboard shortcuts but the symbols that Mac uses is kinda different.

The sequence of symbols in a shortcut means that these keys should all be pressed in order to have the desired action be invoked. This does not mean though, that for example a shortcut needs 3 key buttons, you would need to have 3 key buttons pressed at the same time. You can either press 1 of them first, then the 2nd (while still having the 1st key pressed), then the 3rd. The same way you do with 2 key button shortcuts under Windows. Here is a small guide for you noobs out there.

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(No Ratings Yet)
 Loading ...