Selasa, 19 Mei 2009

php

Salam!
Without even looking at the Syntax differences between the two, PHP Bahkan tanpa melihat Sintaks perbedaan antara dua, PHP
and PASCAL are two very different languages. dan sangat Pascal adalah dua bahasa yang berbeda. Unlike a comparison Tidak seperti perbandingan
between other languages such as C and Basic or C++, the differences do antara lain seperti bahasa C dan Basic atau C + +, perbedaan lakukan
not simply lie in how flexible or powerful the languages are but tidak hanya terletak di seberapa fleksibel atau bahasa yang kuat namun
rather in their basic use. bukan di dasar mereka gunakan. At its core PHP is designed as a scripting Pada intinya PHP dirancang sebagai scripting
language to be used server-side while PASCAL is a regular programming bahasa yang akan digunakan server-side sedangkan Pascal adalah sebuah program reguler
language which can be used to write standalone applications. bahasa yang dapat digunakan untuk menulis aplikasi standalone.

PHP has become an incredibly popular language recently. PHP telah menjadi salah satu bahasa yang populer luar biasa baru-baru ini. Its use can Penggunaannya dapat
be seen through out the web, from simple form processing scripts to terlihat keluar melalui web, dari yang sederhana berupa skrip untuk memproses
giant web based applications such as MediaWiki, the engine which raksasa aplikasi berbasis web seperti MediaWiki, mesin yang
drives http://www.wikipedia.com . drive http://www.wikipedia.com. PHP is a scripting language, so in PHP adalah bahasa scripting, sehingga dalam
terms of use and flexibility it has a lot in common with other persyaratan penggunaan dan fleksibilitas memiliki banyak kesamaan dengan lainnya
scripting languages such as Perl, Python and Ruby. bahasa scripting seperti Perl, Python dan Ruby.

PHP is designed to be run server-side and is primarily used to enhance PHP dirancang untuk menjalankan server-side dan terutama digunakan untuk meningkatkan
website functionality. fungsionalitas situs web. So for example if you wanted a program which Jadi, misalnya jika Anda menginginkan sebuah program yang
took user submitted data from a form on your website and added it to a membawa pengguna mengirimkan data dari formulir di website Anda dan ditambahkan ke
database you would want to write a PHP script. database Anda ingin menulis naskah PHP. Scripts can also be Naskah juga dapat
written which parse data, interact with users, etc. The only major parsing data yang ditulis, berinteraksi dengan pengguna, dan lain-lain yang hanya utama
limitation to PHP is that it is designed to run server-side so it batasan untuk PHP adalah dirancang untuk menjalankan server-side sehingga
cannot for most practical purposes to be used to create standalone tidak dapat paling praktis untuk tujuan yang akan digunakan untuk membuat standalone
applications. aplikasi.

This is where PASCAL comes into play. Di sinilah Pascal datang ke dalam bermain. Where PHP is designed to be run Dimana PHP dirancang untuk dijalankan
server-side, PASCAl is designed to be run client side. sisi server, Pascal dirancang untuk dijalankan sisi klien. This mean Ini berarti
instead of a server processing the program and feeding the information daripada server program pengolahan makanan dan informasi
to the end user, PASCAL is used to create programs which run on the untuk pengguna akhir, Pascal digunakan untuk membuat program yang berjalan di
users computer. pengguna komputer.

PASCAL was developed in 1970 by Niklaus Wirth. Pascal dikembangkan pada 1970 oleh Niklaus Wirth. The language has Bahasa memiliki
fallen out of use in recent years in favor of more popular languages jatuh dari digunakan dalam beberapa tahun terakhir dalam nikmat yang lebih populer bahasa
such as C, C++ and Java. seperti C, C + + dan Java. Some of the notable things that have been Beberapa hal penting yang telah
developed in PASCAL include large portions of the original Macintosh dikembangkan dalam Pascal termasuk besar porsi yang asli Macintosh
Operating System as well as the typesetting system TeX. Sistem operasi serta huruf sistem TeX.

http://en.wikipedia.org/wiki/PASCAL http://en.wikipedia.org/wiki/PASCAL

If you wanted to write a piece of shareware or a regular program which Jika Anda ingin menulis bagian dari shareware atau program yang biasa
stands alone and does not require a server then PASCAL (instead of berdiri sendiri dan tidak memerlukan server kemudian Pascal (bukan
PHP) is what you would want to use. PHP) adalah apa yang anda ingin gunakan. In practical terms though not Dalam hal praktis walaupun tidak
much is written in PASCAL these days. banyak ditulis dalam Pascal ini.

----- Code Samples --------------- ----- Kode Sampel ---------------
Below you'll find some code samples for the two languages which Di bawah ini Anda akan menemukan beberapa contoh kode untuk dua bahasa yang
illustrate some of the syntax differences for some of the more common menggambarkan beberapa sintaks untuk beberapa perbedaan yang lebih umum
functions. fungsi.

*** File Format *** Format File *** ***
A PHP script is saved with the format filename.php. J skrip PHP disimpan dengan format filename.php. When placed on a Ketika ditempatkan pada
PHP enabled server and run it will be interpreted by the server's PHP PHP diaktifkan server dan menjalankannya akan diinterpretasikan oleh server PHP
parser and executed. parser dan dijalankan.

A Pascal program on the other hand is written in a text editor and J Pascal program di sisi lain ditulis dalam editor teks dan
then compiled which creates an executable program with the extension dikompilasi yang kemudian menciptakan sebuah program executable dengan ekstensi
(on a PC) .exe. (pada PC). exe.

*** Beginning and Ending *** *** Awal dan Akhir ***
PHP scripts begin with the tag: Skrip PHP diawali dengan tag:

So a script would look like this... Jadi naskah akan terlihat seperti ini ...



... ... Your script here ... Anda skrip di sini ...

?> ?>

In PASCAL programs start with the "Program" keyword and then the main Dalam Pascal program dimulai dengan "Program" dan kata kunci utama
block of code is contained within begin and end tags. blok kode yang terdapat dalam memulai dan mengakhiri tag. So a sample Jadi contoh
PASCAL program would look like this... Pascal program akan terlihat seperti ini ...

program YourProgram(input, output) Program YourProgram (input, output)
begin mulai
... ... Your Code Goes Here ... Anda Kode Goes Here ...
end akhir

*** Basic Variables *** Variabel *** Dasar ***
PHP does not have defined variable types. PHP tidak memiliki variabel jenis. As a result all variables Akibatnya semua variabel
are prefixed with $. yang diawali dengan $. So the variable named "variable" would look Sehingga variabel yang bernama "variabel" akan terlihat
like $variable. seperti $ variabel.

Variables in Pascal are similar to those in C and other languages. Variabel dalam Pascal adalah serupa dengan yang ada di C dan bahasa lain.
Check out this nice tutorial for examples on how to define the various Check out this nice tutorial untuk contoh bagaimana menentukan berbagai
variable types in PASCAL. jenis variabel dalam Pascal.

http://www.geocities.com/SiliconValley/Horizon/5444/pas005.htm http://www.geocities.com/SiliconValley/Horizon/5444/pas005.htm

*** If/Then *** *** Jika / Kemudian ***
If/Then statements in PHP are fairly easy to write. Jika / Lalu pernyataan di PHP yang cukup mudah untuk menulis. It begins with an Dimulai dengan
If(X) where represents the condition to be evaluated. Jika (X) yang merupakan kondisi yang akan dievaluasi. If it evaluates Jika menilai
to true then the code contained inside the following set of brackets untuk benar maka kode yang di dalam kurung berikut set
is executed. dijalankan. For example... Misalnya ...

if (condition_to_be_evaluated) if (condition_to_be_evaluated)
{ (
... ... if true this code executes ... jika benar melaksanakan kode ini ...
} )

----- -----
$x = 1 $ x = 1
$y =1 $ y = 1

if ($x == $y) if ($ x == $ y)
{ (
print "Because X and Y are both equal to 1, the condition will print "Karena X dan Y keduanya sama dengan 1, kondisi akan
evaluate to true which means this code will be exacuted"; mengevaluasi ke true yang berarti kode ini akan exacuted ";
} )

PASCAL looks a lot different (and a lot less clean if you ask me) when Pascal terlihat banyak berbeda (dan banyak yang kurang bersih jika Anda bertanya kepada saya), ketika
it comes to if/then statements. jika ia datang ke / kemudian pernyataan. The basic structure of an if/then Dasar struktur yang jika / maka
statement in PASCAl is: Pernyataan dalam Pascal adalah:

if BooleanExpression then maka jika BooleanExpression
begin mulai
...this code gets evaluated ... kode ini akan dievaluasi
end; akhir;

In the above example, the condition you want to test goes where Dalam contoh di atas, kondisi yang akan diuji di tempat
"BooleanExpression" is. "BooleanExpression" itu. If this evaluates to true then the code Jika ini benar, maka untuk mengevaluasi kode
within the begin and end keywords gets executed. di akhir kata kunci dan mulai dijalankan.

*** Output *** Output *** ***
Outputting to the screen is very simple in both languages. Outputting ke layar sangat sederhana dalam kedua bahasa. The Itu
easiest way in PHP is to write: cara termudah di PHP adalah untuk menulis:

print "What you want to output goes here"; cetak "Apakah Anda ingin output di sini";

In PASCAL the syntax goes as follows: Dalam sintaks Pascal berjalan sebagai berikut:

Writeln('What you want to output goes here'); Writeln ( 'Apa yang anda ingin output di sini');


*** For Loops *** *** Untuk loops ***
In PHP for loops look like this: Di PHP untuk loops terlihat seperti ini:

for (initial value x; condition for loop to finish; closing expression) for (nilai awal x; kondisi loop untuk menyelesaikan; penutupan ekspresi)
{ (
code kode
} )

A practical example would be: Sebuah contoh praktis akan:

for ($x=0; $x<10;> for ($ x = 0; $ x <10;>
{ (
print x; cetak x;
} )

This loop sets the initial value to x ($x=0) and then runs the code Lingkaran ini menetapkan nilai awal untuk x ($ x = 0) dan kemudian menjalankan kode
print x; over and over until $x is greater then 10. cetak x; berulang sampai $ x lebih besar kemudian 10. Each loop $x is Setiap lingkaran adalah $ x
raised by 1. dibangkitkan oleh 1.

On the Pascal side For loops take on this structure: Di samping Pascal Untuk mengambil loops pada struktur ini:

FOR var_name := initial_value TO final_value DO UNTUK var_name: = initial_value TO DO final_value
begin mulai

...your code goes here... ... kode Anda di sini ...

end; akhir;

----- Helpful Links ----- ----- Link -----
A number of helpful tutorials exist for both languages which will Sejumlah bermanfaat ada tutorial untuk kedua bahasa yang akan
further illustrate the syntax differences between the two. sintaks lebih menggambarkan perbedaan antara keduanya. If listed Jika terdapat
a number of the best ones below. sejumlah orang yang terbaik di bawah ini.

*** PHP *** *** *** PHP

PHP - A Simple Tutorial PHP - A Simple Tutorial
http://us2.php.net/tut.php http://us2.php.net/tut.php

W3schools PHP Tutorial W3schools PHP Tutorial
http://www.w3schools.com/php/default.asp http://www.w3schools.com/php/default.asp

PHP Tutorial Part 1 Tutorial PHP Bagian 1
http://www.freewebmasterhelp.com/tutorials/php http://www.freewebmasterhelp.com/tutorials/php

PHP Tutorial - Introduction PHP Tutorial - Pendahuluan
http://www.tizag.com/phpT/ http://www.tizag.com/phpT/

*** PASCAL *** Pascal *** ***

Learn Pascal Tutorial Belajar Pascal Tutorial
http://www.taoyue.com/tutorials/pascal/ http://www.taoyue.com/tutorials/pascal/

Delphi and Pascal Programming Tutorial Delphi dan Pemrograman Pascal Tutorial
http://ourworld.compuserve.com/homepages/TK_Boyd/Tut.htm http://ourworld.compuserve.com/homepages/TK_Boyd/Tut.htm

Roby's Pascal Tutorial Roby's Pascal Tutorial
http://www.geocities.com/SiliconValley/Park/3230/pas/pasles00.html http://www.geocities.com/SiliconValley/Park/3230/pas/pasles00.html


I hope that this answered your questions. Saya harap ini menjawab pertanyaan Anda. If you need anything Jika anda memerlukan sesuatu
cleared up, please request a clarification before rating my answer and dihapus atas, silakan meminta klarifikasi sebelum saya dan penilaian
I will be more then happy to help. Saya kemudian akan lebih senang untuk membantu.

Best, Terbaik,
djbaker-ga djbaker-ga

Request for Answer Clarification by whitehat88-ga on 07 Jun 2005 10:53 PDT Jawaban permintaan penjelasan oleh whitehat88-ga pada 07 Jun 2005 10:53 PDT
 Can you show me some more code difference using snippets? Tolong tunjukkan saya lebih perbedaan menggunakan kode snippet? 

Clarification of Answer by djbaker-ga on 07 Jun 2005 11:01 PDT Jawaban oleh klarifikasi dari djbaker-ga pada 07 Jun 2005 11:01 PDT
 Sure. Pasti. What types of code snippets are you looking for, anything specific? Jenis potongan kode yang Anda cari, sesuatu yang spesifik? 

Request for Answer Clarification by whitehat88-ga on 12 Jun 2005 01:44 PDT Jawaban permintaan penjelasan oleh whitehat88-ga pada 12 Jun 2005 01:44 PDT
 it would be good if a short program in pascal is translated into php, ia akan baik jika singkat program pascal diterjemahkan ke dalam php,
let me know if it's possible :) let me know if it's possible:)

Clarification of Answer by djbaker-ga on 12 Jun 2005 10:05 PDT Jawaban oleh klarifikasi dari djbaker-ga pada 12 Jun 2005 10:05 PDT
 Here is a very famous programming example called "The Towers of Hanoi". Berikut ini adalah contoh program yang sangat terkenal yang disebut "The Towers of Hanoi".

**Pascal** Pascal ** **

(* The Towers Of Hanoi *) (* The Towers of Hanoi *)
(* Pascal *) (* Pascal *)
(* Copyright (C) 1998 Amit Singh. All Rights Reserved. *) (* Copyright (C) 1998 Amit Singh. Semua hak dilindungi Undang-Undang. *)
(* http://hanoi.kernelthread.com *) (* Http://hanoi.kernelthread.com *)
(* *) (* *)
(* Tested under p2c and the GNU Pascal compiler *) (* Tested p2c bawah dan GNU Pascal compiler *)

PROGRAM Hanoi(input, output); PROGRAM Hanoi (input, output);

VAR N:integer; Var N: integer;

PROCEDURE dohanoi(N, Tfrom, Tto, Tusing : integer); PROSEDUR dohanoi (N, Tfrom, Tto, Tusing: integer);
BEGIN BEGIN
if N > 0 THEN jika N> 0 THEN
BEGIN BEGIN
dohanoi(N-1, Tfrom, Tusing, Tto); dohanoi (N-1, Tfrom, Tusing, Tto);
writeln('move ', Tfrom:1, ' --> ', Tto:1); writeln ( 'memindahkan', Tfrom: 1, '->', Tto: 1);
dohanoi(N-1, Tusing, Tto, Tfrom); dohanoi (N-1, Tusing, Tto, Tfrom);
END END
END; END;

BEGIN BEGIN
write('N = ? '); menulis ( 'N =');
readln(N); readln (N);
writeln; writeln;
dohanoi(N, 1, 3, 2) dohanoi (N, 1, 3, 2)
END. Akhir.

**PHP** PHP ** **



/* / *
* The Towers Of Hanoi * The Towers of Hanoi
* PHP * PHP
* Copyright (C) 2001 Amit Singh. * Copyright (C) 2001 Amit Singh. All Rights Reserved. Semua hak dilindungi Undang-Undang.
* http://hanoi.kernelthread.com * Http://hanoi.kernelthread.com
*/ * /

$HANOI_MAXDISKS = 4; $ HANOI_MAXDISKS = 4;

function PHP_printmove($from, $to) fungsi PHP_printmove ($ from, $ ke)
{ (
print "move $from ==> $to print "$ pindah dari ==> $ ke
\n"; \ n ";
} )

function PHP_movedisk($from, $to, $using, $N) fungsi PHP_movedisk ($ from, $ to, $ menggunakan, $ N)
{ (
if ($N <= 1) { if ($ N <= 1) (
PHP_printmove($from, $to); PHP_printmove ($ from, $ ke);
} else { ) Else (
PHP_movedisk($from, $using, $to, $N - 1); PHP_movedisk ($ from, $ gunakan, ke $, $ N - 1);
PHP_printmove($from, $to); PHP_printmove ($ from, $ ke);
PHP_movedisk($using, $to, $from, $N - 1); PHP_movedisk ($ gunakan, ke $, $ from, $ N - 1);
} )
} )

function PHP_hanoierror() fungsi PHP_hanoierror ()
{ (
GLOBAL $HANOI_MAXDISKS; GLOBAL $ HANOI_MAXDISKS;
GLOBAL $HTTP_HOST; GLOBAL $ HTTP_HOST;
GLOBAL $PHP_SELF; GLOBAL $ PHP_SELF;

print "You must specify the number of disks (maximum $HANOI_MAXDISKS) as an print "Anda harus menentukan jumlah disk (maksimum HANOI_MAXDISKS $) sebagai
appropriate integer argument, for example: sesuai argumen integer, misalnya:

http://$HTTP_HOST$PHP_SELF?N http:// $ HTTP_HOST $ PHP_SELF? N
where 1 <= N <= $HANOI_MAXDISKS"; dimana 1 <= N <= $ HANOI_MAXDISKS ";
} )

function PHP_hanoi($N) fungsi PHP_hanoi (N $)
{ (
GLOBAL $HANOI_MAXDISKS; GLOBAL $ HANOI_MAXDISKS;

if (!ereg("^[0-9]+", $N) || ($N > $HANOI_MAXDISKS)) { if (! ereg ( "^ [0-9] +", $ N) | | ($ N> $ HANOI_MAXDISKS)) (
PHP_hanoierror(); PHP_hanoierror ();
} else { ) Else (
PHP_movedisk(1, 3, 2, $N); PHP_movedisk (1, 3, 2, $ N);
} )
} )
?> ?>


if ($argc != 1) { if ($ argc! = 1) (
PHP_hanoierror(); PHP_hanoierror ();
} else { ) Else (
PHP_hanoi($argv[0]); PHP_hanoi ($ argv [0]);
} )
?> ?>

Tidak ada komentar:

Posting Komentar