PHP and Web Technologies Freak
This article explains 2 simple commands that most people want to know when they are using Linux. You can find the size of a directory and find the amount of free space, which is on your computer. The command you use to specify the directory size is “du”. And, to the free space you can “df.”
All information in this article can be found in the man pages for du and df. In case you get bored reading the man pages, and you want your work quickly, then this article is for you.
Read the rest of this entry »
Another simple trick;
$timestamp="1243949621"; echo date("d-m-Y", $timestamp); //02-06-2009
Here’s an easy to use function to copy entire directories
function dir_copy($src,$dst) { $dir = opendir($src); @mkdir($dst); while(false !== ( $file = readdir($dir)) ) { if (( $file != '.' ) && ( $file != '..' )) { if ( is_dir($src . '/' . $file) ) { dir_copy($src . '/' . $file,$dst . '/' . $file); } else { copy($src . '/' . $file,$dst . '/' . $file); } } } closedir($dir); }
CSS designers allways have same problem; when the page is short there is no scroll in firefox but there is in ie. We can’t remove IE’s scrolls but we can put scrolls to Firefox.
Here we go;
html { overflow: -moz-scrollbars-vertical; }
Simple and clear;
substr_replace($string ,"",-1);
Here is the list of some free feed directories;
http://www.feedest.com/feedAdd.cfm
http://www.2rss.com/index.php
http://www.fybersearch.com/add-url.php
Read the rest of this entry »
we’ll go it with get_defined_vars() function. get_defined_vars returns multidimensional array with all defiend variables in PHP
here we go ; Read the rest of this entry »
I am going to divide each part as follows
1. Plan the layout of the filesystem with the new drive
2. Partition the new hard drive
3. Format the new partitions
4. Test the new space
5. Copy data from old to new partition (optional)
6. Edit /etc/fstab
7. Reboot
8. Remove old data (optional)
Here is the details about each one.
Read the rest of this entry »
if you want to backup and restore your big MySQL databases you need better solution than phpmyadmin
So here we go;
To dump all databases to a file:
$ mysqldump -u dbuser -pdbpass --all-databases > all-databases.sql
To dump a single database to a file:
$ mysqldump -u dbuser -pdbpass somedb > somedb.sql
Dump InnoDB in a single transaction:
$ mysqldump -u dbuser -pdbpass --single-transaction somedb > somedb.sql
To restore:
$ mysql -u dbuser -pdbpass somedb < somedb.sql
There are several methods get a file extension using PHP:
<? $filename = 'myfile.jpg'; // 1. The "explode/end" method $ext = end(explode('.', $filename)); // 2. The "strrchr" method $ext = substr(strrchr($filename, '.'), 1); // 3. The "strrpos" method $ext = substr($filename, strrpos($filename, '.') + 1); // 4. The "preg_replace" method $ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename); // 5. The "never use this" method // From: http://php.about.com/od/finishedphp1/qt/file_ext_PHP.htm $exts = split("[/\\.]", $filename); $n = count($exts)-1; $ext = $exts[$n]; ?>