Script Menghitung Execution Time

Tambahkan fungsi berikut ini di awal script dan panggil langsung fungsi pertamanya.

function getTime(){
		$a = explode (' ',microtime());
		return(double) $a[0] + $a[1];
	} 

function excTime($Start){
		$End = getTime();
		echo "<div style='font-size:11px;color:#6599DD;margin:5px 0;'>this page need ".number_format(($End - $Start),4)." secs too load</div>";
	}

$Start = getTime();

Pada akhir script tulis script berikut

excTime($Start);

Install Java di Linux Centos

Berikut ini adalah langkah2 jika anda ingin menginstall java di linux

1. Download file jdk kemudian misalnya kita taruh di /usr/local

2. Masuk ke direktori /usr/local dan extract file jdk anda

# cd /usr/local
# tar xvzf jdk1.5.0.tgz

3. Tambahkan path java ke bash linux menggunakan editor vi

# cd
# vi .bash_profile

4. Ubah .bash_profile anda menjadi berikut ini

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME
export JAVA_HOME=/usr/local/jdk1.5.0
export PATH=$PATH:$JAVA_HOME/bin

~
~
~
~
".bash_profile" 16L, 262C

penambahan dimualai dari export JAVA_HOME sampai $JAVA_HOME/bin

5. Simpan kalau sudah anda edit, kemudian ketik kode berikut agar .bash_profile anda reload

# . .bash_profile

6. Kalau sudah, silahkan anda cek apakah java sudah terinstall di linux anda

# javac

output nya:

Usage: javac  
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are used
  -classpath           Specify where to find user class files
  -cp                  Specify where to find user class files
  -sourcepath          Specify where to find input source files
  -bootclasspath       Override location of bootstrap class files
  -extdirs             Override location of installed extensions
  -endorseddirs        Override location of endorsed standards path
  -d              Specify where to place generated class files
  -encoding        Specify character encoding used by source files
  -source           Provide source compatibility with specified release
  -target           Generate class files for specific VM version
  -version                   Version information
  -help                      Print a synopsis of standard options
  -X                         Print a synopsis of nonstandard options
  -J                   Pass  directly to the runtime system

Menghapus Array Berdasar Value

Jika kita ingin menghapus array item berdasarkan value adalah berikut ini script nya

Misalkan kita memiliki sebuah array kemudian kita ingin menghapus array yang memiliki value ‘candra’

$array = array('anggi','budi','candra');

foreach ($array as $key => $value) {
      if (is_null($value) || $value=="candra") {
        unset($files[$key]);
      }
    }

maka array yang tersisa adalah

$array = array('anggi','budi');

bisa dicek menggunakan perintah

print_r($array);