Jan 09

Reading Files in PHP

Programming by Imam | No Comments »

There are several ways to open and display files, and each has its uses. You don’t need to know all the ways to read filesit is probably best to learn one and stick with it for your own code. However, you will almost certainly come across each of these methods in other people’s code, because everyone has her own method of getting things done.

readfile( )
If you want to output a file to the screen without doing any form of text processing on it whatsoever, readfile( ) is the easiest function to use. When passed a filename as its only parameter, readfile( ) will attempt to open it, read it all into memory, then output it without further question. If successful, readfile( ) will return an integer equal to the number of bytes read from the file.

If unsuccessful, readfile( ) will return false, and there are quite a few reasons why it may fail. For example, the file might not exist, or it might exist with the wrong permissions.

Here is an example script:

$testfile = @readfile(“test.txt”);
// OR "@readfile("c:\\boot.ini");" if you are using Windows
if (!$testfile) {
print “Could not open file.\n;
}

Popularity: 9% [?]

Sep 04

Install PHP Pear di windows

Programming by Imam | No Comments »

Untuk mengisntall Pear diwindows langkah2nya sebagai berikut :

masuk ke dalam folder PHP kemudian jalankan pear.bat dengan cara dobel klik. Akan muncul tampilan untuk melakukan instalasi. ikuti langkah2nya sampai selesai.

Popularity: 4% [?]

Aug 23

Membuat Thumbnails Image make PHP

Programming, Tips by Imam | No Comments »

Berikut script untuk membuat thumbnail images. :

Popularity: 4% [?]

Oct 07

Bikin file pdf make script PHP

Programming by Imam | 3 Comments »

Malam minggu maen ketemapt om Alan nyobain script2 PHP sama om duduls . Script PHP untuk membuat file PDF

<?php
// Nilai ukuran point (1/72 dari inci )
$ukuran_font = 72; // besar font 1 inci
$Tinggi_Halaman = 612; // tinggi halaman 8.5 inci
$Lebar_Halaman = 792; // lebar halaman 11 inci

// Tampilkan pesan default jika berhasil
if (strlen(trim($_GET[’pesan’]))) {
$pesan = trim($_GET[’pesan’]);
} else {
$pesan = ‘Bikin File PDF!’;
}

// Buat dokumen pdf baru di memory
$pdf = pdf_new( );
pdf_open_file($pdf, ”);

// Tambah halaman dengan ukuran dokumen 11″x8.5″
pdf_begin_page($pdf, $Lebar_Halaman, $Tinggi_Halaman);

// Pilih jenis font Verdana dengan ukuran 72 point
$font = pdf_findfont($pdf, “Verdana”, “winansi”, 0);
pdf_setfont($pdf, $font, $ukuran_font);

// Tampilkan pesan di tengah halaman
pdf_show_boxed($pdf, $pesan, 0, ($Tinggi_Halaman-$ukuran_font)/2,
$Lebar_Halaman, $ukuran_font, ‘center’);

// Akhir dari dokumen dan halaman
pdf_end_page($pdf);
pdf_close($pdf);
// Mengambil isi dari dokumen dan menghapusnya
$pdf_dok = pdf_get_buffer($pdf);
pdf_delete($pdf);

// Kirim headers dan isi dari dokumen
header(’Content-Type: application/pdf’);
header(’Content-Length: ‘ . strlen($pdf_dok));
print $pdf_dok;
?>

Untuk selebihnya silahkan dicoba aja function2 lainnya ya :D. Sekarang udah jam setengah 3 sebelum sahur mo tiduran bentar ah..:P. Om Alan masih maen RO ajah..hayah..

Popularity: 5% [?]