Open Source Web Development with LAMP Using Linux, Apache, MySQL, Perl, and PHP [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Open Source Web Development with LAMP Using Linux, Apache, MySQL, Perl, and PHP [Electronic resources] - نسخه متنی

James Lee, Brent Ware

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید










12.2 Embedding PHP Into HTML


There are several ways to embed PHP code into HTML documents. One way is to put the PHP code within the tags <? ... ?>:


<? echo "hello, world!"; ?>

Most PHP programmers choose this syntax. If PHP is combined with XML, however, there are conflicts with this syntax. In XML the <? ... ?> construct is a special thing called a processing instruction. If PHP and XML are needed in the same file, one can use the alternative PHP tag <?php ... ?>:


<?php echo "hello, world!"; ?>

Some HTML editors (such as FrontPage) don't like processing instructions, so another alternative is to use the <SCRIPT> tag. This is the syntax:


<SCRIPT LANGUAGE="php"> echo "hello, world!"; </SCRIPT>

And last but not least, the final way is to use a style similar to one in Mason: the <% ... %> tag:


<% echo "hello, world!"; %>

We are not using XML in these examples, so we don't need to use the <?php ... ?> syntax. Also, because our favorite HTML editors are vi and emacs, we don't need the <script> syntax (we don't use FrontPage or other HTML editorsif you do, plan accordingly). We use the first style in our examples.


/ 136