<?php
function get_search_phrase($referer){
$key_start = 0;
$search_phrase = “”;
// used by google, msn, alta vista, ask jeeves, all the web, teoma, wisenut, search.com
if (strpos($referer, ‘q=’) !== false) $key_start = strpos($referer, ‘q=’) + 2;
// if present, get the search phrase from the referer
if ($key_start > 0){
if (strpos($referer, ‘&’, $key_start) !== false){
$search_phrase = substr($referer, $key_start, (strpos($referer, ‘&’, $key_start) - [...]
The usage of quotation mark in script PHP very often we meet, maybe can be every script that we make existed the usage of quotation mark referred.
This function randomizes the order of the elements in an array also used together with srand() function.
shuffle() example:
PHP merupakan bahasa pemrograman yang sangat cepat, namun masih banyak cara mengoptimasi PHP tidak hanya sekedar seberapa cepat eksekusi kode.
untuk membuat website tampak lebih dinamis maka tampilan pada website tersebut lebih baik dpat berubah sewaktu - waktu, salah satu trik untuk membuat website anda tampak dinamis adalah menampilkan gambar yang berubah - ubah, berikut ini script untuk dapat menampilkan gambar secara acak
Setelah melakukan instalasi normal terhadap Ubuntu, langkah berikutnya yang dibutuhkan untuk mendapatkan server web Apache dengan PHP nya berikut dengan server database MySQL adalah:
Instalasi web server Apache
# apt-get install apache2
Instalasi database server MySQL
# apt-get install mysql-server
Instalasi php untuk web server Apache
# apt-get install php4
Instalasi MySQL untuk Apache
# apt-get install libapache2-mod-auth-mysql
# apt-get install php4-mysql
Menggunakan PHP untuk mengupload file ke dalam database MySQL kadang dibutuhkan oleh beberapa aplikasi berbasis web. Sebagai contoh untuk menyimpan file-file pdf atau gambar untuk membuat tempat penyimpanan yang bersifat online.
Untuk membuat aplikasi upload ini, langkah pertama buatlah sebuah table dengan menggunakan phpMyAdmin atau langsung dari mysql shell command:
CREATE TABLE upload (
id INT NOT NULL [...]
Fitur php sangatlah banyak, beberapa memang sangat powerful. Namun, pada situasi tertentu 2 atau lebih function dapat digunakan untuk mengatasi masalah yang sama, namun dengan perbedaaan performance.
Mungkin yang paling sering digunakan adalah ereg_replace dan preg_replace. Bila hanya ingin mengganti string, cukup gunakan str_replace karena dengan regular expression di atas akan memakan waktu 10 kali lipat [...]
^ Start of line
$ End of line
n? Zero or only one single occurrence of character ‘n’
n* Zero or more occurrences of character ‘n’
n+ At least one or more occurrences of character ‘n’
n{2} Exactly two [...]
ereg_replace
To delete all signs / symbols from a string, you can use the function with special values:
ereg_replace(”[[:punct:]]”,”,$string);
The following is a set of special values that denote certain common ranges. They have the advantage that also take in account the ‘locale’ i.e. any variant of the local language/coding system.
[:digit:] Only the [...]