1 / 11

PHP: introduction

PHP: introduction. Speaker: Chin-Cheng Chang Date:2007.3.14. Basic Syntax. file name: *.php start: <?php end: ?> end each command: ; variable: $ xxx constant: define(“ xxx ”, x ) annotations: // or /* …… */. Output. echo " something " ; echo $variable;

venice
Télécharger la présentation

PHP: introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PHP: introduction Speaker: Chin-Cheng Chang Date:2007.3.14

  2. Basic Syntax • file name: *.php • start: <?php • end: ?> • end each command: ; • variable: $xxx • constant: define(“xxx”, x) • annotations: // or /* …… */

  3. Output • echo "something"; • echo $variable; • echo CONSTANT; • <br> //換行符號

  4. Echo <?php // test echo command echo "Hello, World!"; /* this is a demo for database */ ?> http://stu.csie.ncnu.edu.tw/~94321517/demo1.php

  5. Variables <?php $text = "World!"; echo "Hello, $text"; echo 'Hello, $text'; ?> http://stu.csie.ncnu.edu.tw/~94321517/demo2.php

  6. Input(1/2) • get <form action="xxx.php" method="get"><input type="text" name="user"><input type="text" name="password"><input type="submit" value="enter"></form>http://stu.csie.ncnu.edu.tw/~beautidays.99/demo3.php • Post <form action="xxx.php" method=“post"><input type="text" name="user"><input type="text" name="password"><input type="submit" value="enter"></form>http://stu.csie.ncnu.edu.tw/~beautidays.99/demo4.php

  7. Input(2/2) • <?php if ($HTTP_POST_VARS['user']) $user_get=$HTTP_POST_VARS['user']; if ($HTTP_POST_VARS['password']) $password_get=$HTTP_POST_VARS['password']; if ($HTTP_GET_VARS['user']) $user_get=$HTTP_GET_VARS['user']; if ($HTTP_GET_VARS['password']) $password_get=$HTTP_GET_VARS['password']; echo "user=" . $user_get; echo "password=" . $password_get;?>http://stu.csie.ncnu.edu.tw/~beautidays.99/xxx.phps

  8. Loop • for (initial state; condition; repeat state){ command;} • for ($i=1; $i<=10; $i++){echo $i . '<br>';} • http://stu.csie.ncnu.edu.tw/~94321517/demo5.php

  9. stu.csie.ncnu.edu.tw • Create a directory under your home directory • mkdir $HOME/www • You may name your default homepage as: • index.html or index.htm or index.php • http://stu.csie.ncnu.edu.tw/~username/ • http://stu.csie.ncnu.edu.tw/~94321517/ • Reference • http://php.igt.com.tw/

  10. Homework #2 • 9x9 Multiplication Table • Mail your source code (with include files, if any) to TA db-ta@ipv6.club.tw • Email Subject: [Database HW2] 92321036 • You can also mail the URLs only. • Two URLs: one for source code (hw2.phps) and one for execution (hw2.php). • Add these hyperlinks to your “database952.html”. • Due: Tuesday 3/20 11:59AM

  11. link指令 • ln 被link的檔案 新增的檔案 ex. ln hw2.php hw2.phps

More Related