----- Original Message -----
From: "aktif03" <[EMAIL PROTECTED]>


> Halo teman-teman semuanya.
> Saya lagi iseng untuk mengamati script PHP. Keisengan itu terletak
> pada tanda <?php ... ?>   <?...?> untuk PHP.
>
> Permasalahannya:
> =>. penulisan satu file untuk script php membutuhkan paling sedikit
> satu <? ... ?>, bila seandainya saya ingin menulis script hanya satu
> file saja tanpa pakai include file/require(), sistem PHP (dalam hal
> ini apache+mysql+php) dapat menerima berapa banyak tanda <? ...?> di
> dalam satu file Php?. Pertanyaan saya ingin karena iseng: pada waktu
> saya iseng-iseng nulis script Php, saya asal-asalan saja meletakkan
> <? ...?> sebanyak lima set, kemudian saya menemukan bahwa ada kalimat
> yang saya tulis di bawah <? ...?> akan tercetak pada baris paling
> atas dari data yang ada.

File yang dibuat untuk script php bisa memuat banyak tanda <? ... ?> atau
<?php ... ?> dalam satu file. Saya rasa 5 itu masih kurang =).

Kemungkinan Anda membuat kesalahan dalam coding HTML-nya. Coba perhatikan
hasil kode HTML yang dibuat oleh PHP itu. Kemungkinan besar sih karena Anda
menggunakan pembuka tabel dan tidak menggunakan penutup tabel, jadinya kacau
balau begitu. Bagusnya sih Anda tunjukkan bagaimana kode PHP/HTML yang Anda
buat.

> Kesimpulan saya:
> - PHP menganut konsep OOP, berarti apa yang saya tulis dari atas ke
> bawah seharusnya perintah-perintah itu dikerjakan secara berurutan
> kecuali ada perintah loop/dan sejenisnya.

Sepertinya Anda sedikit salah persepsi dalam OOP. OOP = Object Oriented
Language, yaitu bagian-bagian suatu coding/script dibagi-bagi menjadi
bagian-bagian kecil, dan dipanggil jika membutuhkan. Jadi jika suatu bagian
dipanggil, dia akan menuju bagian itu, tidak 'mulus' dari atas ke bawah.

> - waktu saya iseng-iseng meletakkan perintah/tulisan itu di antara
> <? ... ?> maka dengan sendirinya browser menampilkan pekerjaannya
> dari atas ke bawah. Lupakan yang lalu/di depan dan kejakan yang
> sekarang ini... namun ingat baik-baik yang terdahulu/leluhurnya kalau
> tidak salah...

Swetau saya nggak begitu. Secara wajar, dari atas ke bawah, kecuali ada
syarat tertentu. Sebaiknya Anda sertakan file PHP yang Anda buat itu supaya
nggak tambah bingung.

> Yang menjadi kepenasaran saya adalah apa fungsi sebenarnya dari
> <? ... ?> dalam file yang bersangkutan sebab saya sudah cari dan baca
> cukup banyak buku, belum ada juga buku yang membahas konsep dasar
> dari <? ... ?> yang lebih dari satu tanda tersebut dalam satu file.

<?php ?> maupun <? ?> merupakan tag pembuka dan penutupo untuk suatu script
PHP. Jika suatu kode program dalam file HTML tidak berada di dalam ke dua
tag itu, berarti adalah kode HTML, bukan kode PHP.

Di manual PHP, bagian Language reference - Basic Syntax, tertulis seperti di
bawah ini. Silakan Anda artikan sendiri =). Intinya kira-kira menegaskan
baha <?php ?> dan sebangsanya digunakan sebagai pembeda antara HTML dan PHP,
dan tanda tersebut bisa digunakan berapapun banyaknya dalam file PHP yang
Anda buat.

LuckyGuy354
IT Beginner

http://www.wiwid-l.net



Escaping from HTML
When PHP parses a file, it simply passes the text of the file through until
it encounters one of the special tags which tell it to start interpreting
the text as PHP code. The parser then executes all the code it finds, up
until it runs into a PHP closing tag, which tells the parser to just start
passing the text through again. This is the mechanism which allows you to
embed PHP code inside HTML: everything outside the PHP tags is left utterly
alone, while everything inside is parsed as code.

There are four sets of tags which can be used to denote blocks of PHP code.
Of these, only two (<?php. . .?> and <script language="php">. . .</script>)
are always available; the others can be turned on or off from the php.ini
configuration file. While the short-form tags and ASP-style tags may be
convenient, they are not as portable as the longer versions. Also, if you
intend to embed PHP code in XML or XHTML, you will need to use the <?php. .
.?> form to conform to the XML.

The tags supported by PHP are:

Example 1.1. Ways of escaping from HTML
copy to clipboard
1.  <?php echo("if you want to serve XHTML or XML documents, do like
this\n"); ?>

2.  <? echo ("this is the simplest, an SGML processing instruction\n"); ?>
   <?= expression ?> This is a shortcut for "<? echo expression ?>"

3.  <script language="php">
       echo ("some editors (like FrontPage) don't
             like processing instructions");
   </script>

4.  <% echo ("You may optionally use ASP-style tags"); %>
   <%= $variable; # This is a shortcut for "<% echo . . ." %>
The first way, <?php. . .?>, is the preferred method, as it allows the use
of PHP in XML-conformant code such as XHTML.

The second way is not available always. Short tags are available only when
they have been enabled. This can be done via the short_tags() function (PHP
3 only), by enabling the short_open_tag configuration setting in the PHP
config file, or by compiling PHP with the --enable-short-tags option to
configure. Even if it is enabled by default in php.ini-dist, use of short
tags are discouraged.

The fourth way is only available if ASP-style tags have been enabled using
the asp_tags configuration setting.

Note:
Support for ASP-style tags was added in 3.0.4.

Note:
Using short tags should be avoided when developing applications or libraries
that are meant for redistribution, or deployment on PHP servers which are
not under your control, because short tags may not be supported on the
target server. For portable, redistributable code, be sure not to use short
tags.

The closing tag for the block will include the immediately trailing newline
if one is present. Also, the closing tag automatically implies a semicolon;
you do not need to have a semicolon terminating the last line of a PHP
block.

PHP allows you to use structures like this:

Example 1.2. Advanced escaping
<?php
if ($expression) {
   ?>
   <strong>This is true.</strong>
   <?php
} else {
   ?>
   <strong>This is false.</strong>
   <?php
}
?>
This works as expected, because when PHP hits the ?> closing tags, it simply
starts outputting whatever it finds until it hits another opening tag. The
example given here is contrived, of course, but for outputting large blocks
of text, dropping out of PHP parsing mode is generally more efficient than
sending all of the text through echo() or print() or somesuch.






------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/IHFolB/TM
--------------------------------------------------------------------~-> 

----------------------------------------------------------
Komunitas MasterWeb Indonesia http://www.master.web.id
----------------------------------------------------------
MWN, Masternya WEBHOSTING di Indonesia, Indo/USA Servers,
Customer Support 24 jam  http://www.masterwebnet.com
----------------------------------------------------------
Sekolah Digital Design Terlengkap  http://www.mwschool.com
----------------------------------------------------------
WebDevelopment,Designing/Programming http://www.dlanet.com
---------------------------------------------------------- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/milis-masterweb/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Kirim email ke