Introduction to PHP

來源:互聯網
上載者:User

標籤:

Part 1: HTML, Meet PHP1. PHP in action

PHP is a programming language that can do all sorts of things:

  • evaluate form data sent from a browser,
  • build custom web content to serve the browser
  • talk to a database
  • send and receive cookies (little packets of data that your browser uses to remember things)

Check out the code in the editor. Looks familiar, doesn‘t it? That‘s because a lot of it is regular old HTML! The PHP code is written in the <?php and ?> . See how it generates numbers, creates lists, and adds text directly to your webpage?

 

index.php

 1 <!DOCTYPE html> 2 <html> 3   <head> 4     <link type=‘text/css‘ rel=‘stylesheet‘ href=‘style.css‘/> 5     <title>PHP!</title> 6   </head> 7   <body> 8     <img src="http://i1061.photobucket.com/albums/t480/ericqweinstein/php-logo_zps408c82d7.png"/> 9     <div class="header"><h1>10       <?php11       $welcome = "Let‘s get started with PHP!";12       echo $welcome;13       ?>14     </h1></div>15     <p><strong>Generate a list:</strong>16       <?php17       for ($number = 1; $number <= 10; $number++) {18         if ($number <= 9) {19             echo $number . ", ";20         } else {21             echo $number . "!";22         }23       }; ?>24     </p>25     <p><strong>Things you can do:</strong>26       <?php27         $things = array("Talk to databases",28         "Send cookies", "Evaluate form data",29         "Build dynamic webpages");30         foreach ($things as $thing) {31             echo "<li>$thing</li>";32         }33         34         unset($thing);35       ?>36     </p>37     <p><strong>This jumbled sentence will change every time you click Submit!<strong></p>38     <p>39       <?php40         $words = array("the ", "quick ", "brown ", "fox ",41         "jumped ", "over ", "the ", "lazy ", "dog ");42         shuffle($words);43         foreach ($words as $word) {44             echo $word;45         };46         47         unset($word);48       ?>49     </p>50   </body>51 </html

 

Introduction to PHP

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.