16
By Luo Xuan PHP

By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Embed Size (px)

Citation preview

Page 1: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

By Luo Xuan

PHP

Page 2: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Foreword

• Some may have learned

Page 3: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

What is PHP?• “PHP: Hypertext Preprocessor” ,超文本预处理语言

• Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf

• a widely used open-source general-purpose scripting language

• especially suited for web development • can be embedded into HTML

Page 4: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Usage

• Server-side scripting• Eg.– Collect form data– Generate dynamic page content– Send and receive cookies.

Page 5: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Dynamic Web Page• What is Dynamic Web Page?– Dynamic web pages are web sites that are generated at

the time of access by a user or change as a result of interaction with the user.

----Wikipedia

• Why Dynamic Web Page Popular?– Static: few changes and web pages– Dynamic: automatically build and renew web pages

according to the databases, i.e. only changes to the databases needed.

Page 6: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Language Feature in Details

• Embedded in Html• Easy Type• Easy String• Easy Array• Easy Form• Easy E-mail

Page 7: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Embedded in HTML• <html>

<head> <title>PHP Tes</title>

</head><body>

//<?php…?><?php echo "<p>Hello World</p>"; ?>

</body></html>

Page 8: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Easy Type• <?php

$txt = "Hello World!"; $number = 16;?>

• No need for type declaration• Automatic type assignment

Loose Type

Page 9: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Easy String• “.”• <?php

$txt1="Hello World"; $txt2="1234“; echo $txt1 . " " . $txt2; ?>

• <=>“$txt1 $txt2”

• <?php echo strpos("Hello world!","world"); ?>

• <?php echo strlen("Hello world!"); ?>

Hello World 1234

6

12

Page 10: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Easy Array• $names = array("Peter","Quagmire","Joe");

• $ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34);

$ages['Peter'] = "32"; $ages['Quagmire'] = "30";$ages['Joe'] = "34";

• foreach

Page 11: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Easy Array

echo "Is " . $families['Griffin'][2] . " a part of the Griffin family?";

Is Megan a part of the Griffin family?

Page 12: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Easy Form//blabla.php //welcome.php

Page 13: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Easy E-mail

Page 14: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Opponents

• ASP• ASP.NET• JSP

Page 15: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

FeaturesPros• Multi-platform: Unix , GUN/Linux,Windows• Easy to learn• Style: Java + C• Speed

– Memory Arrangement

• Embedded into html• Open source:

– Developing– Security

• The Language itself can be modified

– Various functions– Support almost all the databases– Zero Cost

Cons• not suitable for large-scale E-business sites, better for smaller ones• Open Source => different interfaces to different databases

Page 16: By Luo Xuan. Some may have learned “PHP: Hypertext Preprocessor” , 超文本预处理语言 Personal Home Page Tools (PHP Tools) ——Rasmus Lerdorf a widely used open-source

Summary• Very Easy to Learn• “ 如果您需要运行一个具有动态内容、数据库交

互和电子贸易的网站,那么就请继续读下去,因为 PHP 在这方面确实是非常有用的。”