speaker: hsiang-ting fang 1. what is php. history of php. variables data type examples*4 reference...

12
Speaker: Hsiang-Ting Fang 1

Upload: archibald-joseph

Post on 03-Jan-2016

222 views

Category:

Documents


0 download

TRANSCRIPT

Speaker: Hsiang-Ting Fang

1

What is PHP.

History of PHP.

Variables

Data type

Examples*4

Reference

Exercise*3

2

PHP: Hypertext Preprocessor.

Scripting language.

Can be embedded into HyperText Markup Language ( HTML) .

Server-client structure.

3[1]

PHP/FI Created by  Rasmus Lerdorf  in 1995 Personal Home Page Tools Perl script

PHP2 PHP: Hypertext Preprocessor C language

4

Must start with “$”.

Other name rules are the same as C.

External variable

GET/POST COOKIE SESSION

Internal variable

phpinfo(); SERVER

5

Support these data type

6

Data type How to use

Integer $a = 123;$a = 0123;     // Octal$a = 0x12;     // Hex

Float $a = 1.234;$a = 1.2e3;

Array $b[0][] = 567.8;$c = array(9, 10, 'A');

String $a = ‘Hello World.’;$a = “Hello world!” ;

Object class foo {    function do_foo () {       echo “Doing foo.”;   }}$bar = new foo;$bar -> do_foo ();

http://voip.com.ncnu.edu.tw/Summer2011/PHP/ex/example1.php

<?php/*Edited by ClaudiaJuly 21, 2011*/ $tmp = "Hello world!" ; //This is a string echo $tmp ; #print the variable?>

7

http://voip.com.ncnu.edu.tw/Summer2011/PHP/ex/example2.php<?php $an1 = "dog"; $an2 = "cat"; $an3 = "bird"; echo "What I like is a $an3. </br>"; echo 'What I like is a $an3. </br>' ; echo $an1 ." hates ". $an2."." ;?>

8

http://voip.com.ncnu.edu.tw/Summer2011/PHP/ex/example3.php

<html><body><? for ( $i=1; $i<=6; $i++ )   echo "<h" . $i . ">Hello World!</h" . $i . ">\n";?></body></html>

9

Template: http://voip.com.ncnu.edu.tw/Summer2011/PHP/ex/example4.php

Code: http://voip.com.ncnu.edu.tw/Summer2011/PHP/ex/example4.txt

<form name="demo" action="example4.php" method=get>

<select name="num">

<option value=0>0

<option value=1>1

<option value=2>2

<option value=3>3

<option value=4>4

<option value=5>5

<option value=6>6

<option value=7>7

<option value=8>8

<option value=9>9

</select><input

type=submit value="Submit"></form>

10

[1] http://chensh.loxa.edu.tw/php/A_1.php

http://www.php.net/

http://www.lideshare.net/appleboy/php-mysql-2255172

http://zh.wikipedia.org/wiki/PHP

11

What is the difference between POST and GET.( Example4)

Show the 9*9 multiplication table like this link.

Using PHP and from to find out the greatest common divisor. link

12