WWW PHP

Similar documents
Microsoft Word - PHP7Ch01.docx

C++ 程式設計

C/C++ - 函数

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

WWW PHP Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2

untitled

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

epub 61-2

C/C++ - 字符串与字符串函数

untitled

PowerPoint プレゼンテーション

Microsoft Word - 第3章.doc

untitled

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

C/C++ - 字符输入输出和字符确认

数据结构与算法 - Python基础

國立中山大學學位論文典藏.PDF

02

Microsoft Word - 01.DOC

天津天狮学院关于修订2014级本科培养方案的指导意见

投影片 1

目录

<4D F736F F D C9CFB0EBC4EACFB5CDB3BCAFB3C9CFEEC4BFB9DCC0EDCAA6C9CFCEE7CAD4BEED>

C/C++语言 - 运算符、表达式和语句

, 即 使 是 在 昏 暗 的 灯 光 下, 她 仍 然 可 以 那 么 耀 眼 我 没 有 地 方 去, 你 会 带 着 我 么 杜 晗 像 是 在 嘲 笑 一 般, 嘴 角 的 一 抹 冷 笑 有 着 不 适 合 这 个 年 龄 的 冷 酷 和 无 情, 看 着 江 华 的 眼 神 毫 无 温

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc

ebook4-12

untitled

PowerPoint Presentation

ebook70-13

untitled

Microsoft PowerPoint - TTCN-Introduction-v5.ppt


C/C++程序设计 - 字符串与格式化输入/输出

莊 子

HKG_ICSS_FTO_sogobrilingual_100_19Feb2016_31837_tnc

Fuzzy GP

BC04 Module_antenna__ doc

網站安全

untitled

Guide to Install SATA Hard Disks


(Microsoft Word - PK254P\262\331\327\366\312\326\262\341.doc)

untitled

Computer Architecture

untitled

从《动物福,本网站受美国法律保护 利法》看美国的动物保护——萧冰

epub83-1

UTI (Urinary Tract Infection) - Traditional Chinese

Oracle 4

Microsoft Word htm

Improved Preimage Attacks on AES-like Hash Functions: Applications to Whirlpool and Grøstl

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco

Learn_Perl 3-02.pdf

IBM 全 球 企 业 咨 询 服 务 部 中 国 五 矿 筑 起 人 力 资 源 信 息 大 厦 2 回 顾 篇 慎 选 巧 选 软 件 平 台 由 于 五 矿 集 团 下 属 的 很 多 公 司 是 最 近 几 年 才 加 盟 的 新 成 员 企 业, 这 些 公 司 所 应 用 的 人 力 资

MATLAB 1

天仁期末個人報告1.PDF

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2

第 4 章 XMLHttpRequest 对象 AJAX AJAX 2 iframe AJAX iframe XMLHttpRequest JavaScript iframe AJAX XMLHttpRequest XMLHttpRequest Server Access Object Web XM

hks298cover&back

C语言的应用.PDF

<4D F736F F D C6573ABC8A4E1A8CFA5CEBBA1A9FAAED1>

1. 2. Flex Adobe 3.

国 培 简 讯 国 培 计 划 (2012) 示 范 性 集 中 培 训 项 目 国 培 计 划 (2012) 中 小 学 教 师 示 范 性 集 中 培 训 暨 中 西 部 农 村 教 师 集 中 培 训 中 小 学 骨 干 教 师 北 京 外 国 语 大 学 英 语 学 科 研 修 项 目 毕

jsp

Microsoft Word - SupplyIT manual 3_cn_david.doc

Microsoft Word - template.doc

Data Server_new_.doc

untitled

國 立 政 治 大 學 教 育 學 系 2016 新 生 入 學 手 冊 目 錄 表 11 國 立 政 治 大 學 教 育 學 系 博 士 班 資 格 考 試 抵 免 申 請 表 論 文 題 目 申 報 暨 指 導 教 授 表 12 國 立 政 治 大 學 碩 博 士 班 論

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf("%d", &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf("%

ASP 電子商務網頁設計

Microsoft PowerPoint - ch6 [相容模式]

第一章

Microsoft Word - 苹果脚本跟我学.doc

Knowledge and its Place in Nature by Hilary Kornblith

Microsoft Word - p11.doc

ebook

untitled

RunPC2_.doc

Logitech Wireless Combo MK45 English

CDWA Mapping. 22 Dublin Core Mapping

2014年大学生村官考试公共基础知识:社会革命和社会改革

朝陽科技大學八十八學年度招考碩士班簡章目錄


Tel: Fax: TTP-344M/246M /

投影片 1

目 录 第 一 部 分 档 案 局 概 况 一 主 要 职 责 二 部 门 决 算 单 位 构 成 第 二 部 分 档 案 局 2016 年 度 部 门 预 算 表 一 2016 年 度 市 级 部 门 收 支 预 算 总 表 二 2016 年 度 市 级 部 门 支 出 预 算 表 三 2016

2015 年 度 收 入 支 出 决 算 总 表 单 位 名 称 : 北 京 市 朝 阳 区 卫 生 局 单 位 : 万 元 收 入 支 出 项 目 决 算 数 项 目 ( 按 功 能 分 类 ) 决 算 数 一 财 政 拨 款 一 一 般 公 共 服 务 支 出 二

ebook140-8

Perl

Microsoft Word - 國小中年級.doc

06-4.indd

PTS7_Manual.PDF

(Microsoft Word - Motion Program \270\305\264\272\276\363 \307\245\301\366 \271\327 \270\361\302\367.doc)


Microsoft Word - 口試本封面.doc

K301Q-D VRT中英文说明书141009

入學考試網上報名指南

网易介绍

Transcription:

WWW PHP 2003 1 2

function function_name (parameter 1, parameter 2, parameter n ) statement list function_name sin, Sin, SIN parameter 1, parameter 2, parameter n 0 1 1 PHP HTML 3 function strcat ($left, $right) $combined_string = $left. $right; return $combined_string; function strcat ($left, $right) return $left. $right; <?php function col ()?> </td><td> <??> col() </td><td> HTML 4

PHP4 <?php $makefoo = true; /* We can't call foo() from here since it doesn't exist yet, but we can call bar() */ bar(); if ($makefoo) function foo () echo "I don't exist until program execution reaches me.\n"; 5 /* Now we can safely call foo() since $makefoo evaluated to true */ if ($makefoo) foo(); function bar() echo "I exist immediately upon program start.\n";?> 6

PHP4 A B B A function foo() function bar() echo "I don't exist until foo() is called.\n"; /* We can't call bar() yet since it doesn't exist. */ foo(); /* Now we can call bar(), foo()'s processing has made it accessible. */ bar(); 7 function_name (argument_list); $result = function_name (argument_list); $result function_name argument_list 8

function strcat ($left, $right) return $left. $right; // strcat Hello, woild! $msg = strcat ( Hello,, woild! ); // $msg Hello, world! 9 Pass-by-value References Pass-by-reference 10

Pass-by-value $a = 3; $b = 4; $m = max($a, $b); max ($x, $y) return ($x >= $y)? $x : $y; $a 3 $b 4 3 $x max 4 $y 11 $a = 3; $b = 4; swap($a, $b); swap ($x, $y) $temp = $x; $x = $y; $y = $temp; $a 3 $b 4 3 $x swap 4 $y swap 12 $x $y a b

References PHP 3 $foo name content $foo 3 $bar = & $foo; $foo $bar $foo 3 $bar 13 Pass-by-reference & function inc (& $x) $x++; $a = 10; inc($a); echo $a; // 11 function inc ($x) $x++; $a = 10; inc($a); echo $a; // 10 14

$a = 3; $b = 4; swap($a, $b); swap (&$x, &$y) $temp = $x; $x = $y; $y = $temp; $a $b $x $y swap swap x y a b 15 function makecoffee ($type = "cappuccino ) return "Making a cup of $type.\n"; echo makecoffee (); // Making a cup of cappuccino echo makecoffee ("espresso"); // Making a cup of espresso 16

func_num_args ( ) : func_get_arg ( $n ) : $n func_get_args ( ) function foo() $numargs = func_num_args(); echo "Number of arguments: $numargs<br>\n"; if ($numargs >= 2) echo "Second argument is: ". func_get_arg (1). "<br>\n"; $arg_list = func_get_args(); for ($i = 0; $i < $numargs; $i++) echo "Argument $i is: ". $arg_list[$i]. "<br>\n"; foo (1, 2, 3); 17 PHP $a = 3; // $a is a global variable. function foo () $a += 100; // $a is a local variable. foo(); echo $a; // print global $a, i.e., 3. 18

global $a = 1; $b = 2; function Sum() global $a, $b; $a = 1; $b = 2; function Sum() // global $a, $b; $b = $a + $b; $b = $a + $b; Sum(); echo $b; // 3 Sum(); echo $b; // 2 19 superglobal global PHP $GLOBALS Contains a reference to every variable which is currently available within the global scope of the script. The keys of this array are the names of the global variables. $_SERVER Variables set by the web server or otherwise directly related to the execution environment of the current script. $_GET Variables provided to the script via HTTP GET. 20

$_POST Variables provided to the script via HTTP POST. $_COOKIE Variables provided to the script via HTTP cookies. $_FILES Variables provided to the script via HTTP post file uploads. $_ENV Variables provided to the script via the environment. $_REQUEST Variables provided to the script via any user input mechanism, and which therefore cannot be trusted.. $_SESSION Variables which are currently registered to a script's session. 21 function test_global() // Most predefined variables aren't "super" and require // 'global' to be available to the functions local scope. global $HTTP_POST_VARS; echo $HTTP_POST_VARS['name']; // Superglobals are available in any scope and do // not require 'global'. Superglobals are available // as of PHP 4.1.0 echo $_POST['name']; 22

static variable function counter () static $count = 0; return $count++; for ($i = 1; $i <= 5; $i++) echo counter(); function counter () $count = 0; return $count++; for ($i = 1; $i <= 5; $i++) echo counter(); 0 1 2 3 4 0 0 0 0 0 23 return function return_one () return 100; function return_two () return array( Fred, 35); 24

Variable Functions () PHP function foo() echo "In foo()<br>\n"; function bar($arg = ' ') echo "In bar(); argument was '$arg'.<br>\n"; PHP echo(), print(), unset(), isset(), empty(), include(), require() $func = 'foo'; $func(); // This calls foo() $func = 'bar'; $func('test'); // This calls bar() 25 Anonymous Functions PHP create_function ($args, $code ) $newfunc = create_function ( '$a, $b', 'return "ln($a) + ln($b) = ".log($a * $b); ); echo "New anonymous function: $newfunc\n"; echo $newfunc(2,m_e)."\n"; // outputs // New anonymous function: lambda_1 // ln(2) + ln(2.718281828459) = 1.6931471805599 26