PHP 4.0编程指南与样例

PHP 4.0编程指南与样例
作 者: 武海平 付小龙
出版社: 人民邮电出版社
丛编项:
版权说明: 本书为公共版权或经版权方授权,请支持正版图书
标 签: php
ISBN 出版时间 包装 开本 页数 字数
未知 暂无 暂无 未知 0 暂无

作者简介

暂缺《PHP 4.0编程指南与样例》作者简介

内容简介

本书首先介绍了PHP的基础知识和编程的基本原理,包括PHP的发展历史、PHP的安装和PHP语言的基本要素,PHP的常量、变量、运算符号、控制语句和函数。在此基础上,本书列举了大量PHP的实际应用例子,并提供了相应的源代码。这些例子分为几个专题,包括使用PHP编写聊天室和留言板程序,使用PHP进行用户认证、数据库处理、图形处理和文件的上载与下载等方面的内容,基本上涵盖了目前网站建设中使用到的主流技术。本书附录给出了PHP4.0常用函数库,使本书还能够作为一本手册供程序员编程的时候查询之用。本书可以作为PHP语言的学习书籍,也可供程序员、高级程序员参考。

图书目录

第1章 PHP基础 1

1.1 PHP的基本概念 1

1.2 PHP的安装 3

1.2.1 在UNIX操作系统上安装PHP 3

1.2.2 PHP在Windows95/98/2000/NT上的安装 17

第2章 PHP变量 20

2.1 PHP的基本语法结构 20

2.1.1 PHP的变量类型 21

2.1.2 PHP的类型转换 27

2.1.3 PHP的预定义变量 28

2.1.4 PHP的外部变量 29

2.1.5 PHP定义的一些常量 30

2.2 PHP的数组操作函数 32

array 32

array_walk 32

arsort 33

asort 34

count 34

current 35

each 35

end 36

key 37

ksort 37

list 38

next 38

pos 39

prev 39

range 39

reset 39

rsort 40

shuffle 41

sizeof 42

sort 42

uasort 43

uksort 43

usort 44

第3章 表达式.运算符与控制语句 46

3.1 PHP的表达式 46

3.2 PHP的运算符 47

算术运算符 47

字符串运算符 49

赋值运算符 49

位运算符 50

逻辑运算符 50

其他运算符号 51

3.3 PHP的控制流程(语句) 51

IF语句 52

ELSE语句 52

ELSEIF语句 53

WHILE语句 54

DO..WHILE语句 55

FOR语句 56

BREAK语句 57

CONTINUE语句 58

SWITCH语句 58

REQUIRE语句 60

INCLUDE语句 60

3.4 PHP的函数 61

第4章 PHP开发数据库应用 65

4.1 数据库操作语言——SQL 65

在表的基本操作中常用SQL命令介绍 66

4.2 PHP数据库应用范例——留言板 71

4.3 PHP数据库应用范例——用户认证 81

4.4 PHP数据库应用范例——自动创建UNIX用户 88

4.5 常用的PHP操作数据库的函数 95

PHP操作SQLServer数据库函数库 95

MySQL数据库函数库 99

Oracle8数据库函数库 111

Oracle数据库函数库 116

Sybase数据库函数库 123

第5章 PHP的安全和用户认证 129

5.1 通信协议和身份认证 129

5.1.1 HTTP协议的特点 130

5.1.2 身份认证在HTTP协议中的困难 130

5.2 Cookie技术简介 131

5.2.1 Cookie的概念 131

5.2.2 Cookie的工作方式 132

5.2.3 Cookie的属性 133

5.3 如何在PHP中使用Cookie 134

5.3.1 设置Cookie 134

5.3.2 接收和处理Cookie 136

5.3.3 删除Cookie 137

5.3.4 使用Cookie的限制 137

5.4 通过Cookie进行身份认证 138

5.4.1 身份认证中需要注意的问题 138

5.4.2 建立身份认证的数据表 138

5.4.3 身份认证的函数设计和实现 139

5.4.4 身份认证的PHP脚本 145

5.5 Session的使用 150

5.5.1 Session的概念 150

5.5.2 Session的工作方式 151

5.5.3 如何在PHP中使用Session 151

第6章 PHP一般函数调用 158

6.1 访问计数器 158

6.2 聊天室 163

6.2.1 聊天室的登录 163

6.2.2 聊天室的显示界面 167

6.2.3 聊天室在线人数监测 168

6.2.4 聊天室指挥中心 171

6.2.5 聊天室的主动更新与被动更新 173

6.3 文件的上载与下载 177

6.3.1 文件上载 178

6.3.2 文件下载 179

6.4 apache服务器专用函数库 184

apache_lookup_uri 184

apache_note 184

Getallheaders 185

virtual 186

6.5 文件系统函数库 186

basename 186

chgrp 186

chmod 187

clearstatcache 187

copy 188

delete 188

dirname 188

diskfreespace 189

fclose 189

feof 189

fgetc 190

fgetcsv 190

fgets 191

fgetss 191

file 191

file_exists 192

fileatime 192

filectime 192

filegroup 192

fileinode 193

filemtime 193

fileowner 193

fileperms 193

filesize 194

filetype 194

flock 194

fopen 194

fpassthru 195

fputs 196

fread 196

fseek 196

ftell 197

fwrite 197

set_file_buffer 197

is_dir 198

is_executable 198

is_file 198

is_link 198

is_readable 199

is_writeable 199

link 199

linkinfo 200

mkdir 200

pclose 200

popen 201

readfile 201

readlink 201

rename 202

rewind 202

rmdir 202

stat 202

lstat 203

symlink 204

tempnam 204

touch 204

umask 204

unlink 205

6.6 PHP选项及相关信息函数库 205

error_log 205

error_reporting 206

getenv 206

get_cfg_var 207

get_current_user 207

get_magic_quotes_gpc 207

get_magic_quotes_runtime 207

getlastmod 208

getmyinode 208

getmypid 208

getmyuid 208

getrusage 209

phpinfo 209

phpversion 209

putenv 210

set_magic_quotes_runtime 210

set_time_limit 210

第7章 PHP的图像操作 211

7.1 使用PHP和GD进行图形处理 211

7.1.1 基本工作原理 211

7.1.2 线形图形 213

7.2 使用VH图形库编写UNIX监控系统 217

7.3 PHP的图形函数 226

GetImageSize 226

ImageArc 227

ImageChar 227

ImageCharUp 227

ImageColorAllocate 228

ImageColorTransparent 228

ImageCopyResized 228

ImageCreate 228

ImageDestroy 229

ImageFilledRectangle 229

ImageFilledPolygon 229

ImageLine 229

ImageRectangle 230

ImageCreateFromGIF 230

ImageGIF 230

ImagePNG 230

ImageCreateFromPNG 231

第8章 PHP中的日期处理 232

8.1 日期与时间处理 232

8.1.1 得到目前的日期和时间 232

8.1.2 日期和时间的显示形式 232

8.1.3 转换现在的日期为UNIX的时间戳值 234

8.1.4 修改日期 235

8.1.5 为PHP添加DateAdd函数 237

8.1.6 为PHP添加DateDiff函数 238

8.2 日期与时间函数库 240

checkdate 240

date 240

strftime 241

getdate 242

gettimeofday 243

gmdate 243

mktime 243

gmmktime 244

time 244

microtime 244

附录 PHP4.0常用函数库 245

·程序执行功能函数库 245

escapeshellcmd 245

exec 245

system 246

passthru 246

·字符串处理函数库 246

AddSlashes 246

bin2hex 246

Chop 247

Chr 247

chunk_split 248

convert_cyr_string 248

crypt 248

echo 249

explode 249

flush 249

get_meta_tags 249

htmlspecialchars 250

htmlentities 251

implode 251

join 251

ltrim 251

md5 251

nl2br 252

Ord 252

parse_str 252

print 253

printf 253

quoted_printable_decode 253

QuoteMeta 253

rawurldecode 253

rawurlencode 254

setlocale 254

similar_text 255

soundex 255

sprintf 255

strchr 256

strcmp 256

strcspn 256

strip_tags 257

StripSlashes 257

strlen 257

strrpos 257

strpos 257

strrchr 258

strrev 258

strspn 258

strstr 259

strtok259

strtolower 259

strtoupper 259

str_replace 260

strtr 260

substr 260

trim 261

ucfirst 261

ucwords 261

·变量处理函数库 261

gettype 261

intval 261

doubleval 262

empty 262

is_array 262

is_double 262

is_float 262

is_int 263

is_integer 263

is_long 263

is_object 263

is_real 263

is_string 263

isset 264

settype 264

strval 264

unset 264

·IMAP电子邮件系统函数库 265

imap_append 265

imap_base64 265

imap_body 265

imap_check 266

imap_close 266

imap_createmailbox 267

imap_delete 267

imap_deletemailbox 267

imap_expunge 267

imap_fetchbody 267

imap_fetchstructure 268

imap_header 269

imap_headers 269

imap_listmailbox 270

imap_listsubscribed 270

imap_mail_copy 270

imap_mail_move 271

imap_num_msg 271

imap_num_recent 271

imap_open 271

imap_ping 272

imap_renamemailbox 272

imap_reopen 272

imap_subscribe 273

imap_undelete 273

imap_unsubscribe 273

imap_qprint 273

imap_8bit 274

imap_binary 274

imap_scanmailbox 274

imap_mailboxmsginfo 274

imap_rfc822_write_address 275

imap_rfc822_parse_adrlist 275

imap_setflag_full 275

imap_clearflag_full 276

imap_sort 276

imap_fetchheader 276

imap_uid 277

imap_getmailboxes 277

imap_getsubscribed 277

imap_msgno 277

imap_search 278

imap_last_error 278

imap_errors 279

imap_alerts 279

imap_status 279

mail 279

·Informix数据库函数库 280

ifx_connect 280

ifx_pconnect 280

ifx_close 281

ifx_query 281

ifx_prepare 282

ifx_do 282

ifx_error 283

ifx_errormsg 283

ifx_affected_rows 284

ifx_getsqlca 284

ifx_fetch_row 285

ifx_htmltbl_result 286

ifx_fieldtypes 286

ifx_fieldproperties 287

ifx_num_fields 287

ifx_num_rows 287

ifx_free_result 288

ifx_create_char 288

ifx_free_char 288

ifx_update_char 288

ifx_get_char 288

ifx_create_blob 289

ifx_copy_blob 289

ifx_free_blob 289

ifx_get_blob 289

ifx_update_blob 290

ifx_blobinfile_mode 290

ifx_textasvarchar 290

ifx_byteasvarchar 290

ifx_nullformat 290

ifxus_create_slob 291

ifx_free_slob 291

ifxus_close_slob 291

ifxus_open_slob 292

ifxus_tell_slob 292

ifxus_seek_slob 292

ifxus_read_slob 292

ifxus_write_slob 293

·LDAP目录协议函数库 293

ldap_add 294

ldap_mod_add 295

ldap_mod_del 295

ldap_mod_replace 295

ldap_bind 296

ldap_close 296

ldap_connect 296

ldap_count_entries 296

ldap_delete 296

ldap_dn2ufn 297

ldap_explode_dn 297

ldap_first_attribute 297

ldap_first_entry 297

ldap_free_result 298

ldap_get_attributes 298

ldap_get_dn 299

ldap_get_entries 299

ldap_get_values 299

ldap_list 300

ldap_modify 300

ldap_next_attribute 301

ldap_next_entry 301

ldap_read 301

ldap_search 302

ldap_unbind 302

·数学运算函数库 302

Abs 303

Acos 303

Asin 303

Atan 303

Atan2 303

base_convert 304

BinDec 304

Ceil 304

Cos 305

DecBin 305

DecHex 305

DecOct 306

Exp 306

Floor 306

getrandmax 306

HexDec 307

Log 307

Log10 307

max 307

min 308

mt_rand 308

mt_srand 308

mt_getrandmax 309

number_format 309

OctDec 310

pi 310

pow 310

rand 310

round 311

Sin 311

Sqrt 311

srand 312

Tan 312

·mcrypt编码函数库 312

mcrypt_get_cipher_name 314

mcrypt_get_block_size 314

mcrypt_get_key_size 314

mcrypt_create_iv 314

mcrypt_cbc 315

mcrypt_cfb 315

mcrypt_ecb 315

mcrypt_ofb 316

·ODBC数据库链接函数库 316

mit 316

odbc_binmode 317

odbc_close 317

odbc_close_all 317

odbc_commit 317

odbc_connect 318

odbc_cursor 318

odbc_do 318

odbc_exec 318

odbc_execute 319

odbc_fetch_into 319

odbc_fetch_row 319

odbc_field_name 320

odbc_field_type 320

odbc_field_len 320

odbc_free_result 321

odbc_longreadlen 321

odbc_num_fields 321

odbc_pconnect 321

odbc_prepare 322

odbc_num_rows 322

odbc_result 322

odbc_result_all 322

odbc_rollback 323

odbc_setoption 323

·FTP文件传输函数库 323

ftp_connect 324

ftp_login 324

ftp_pwd 324

ftp_cdup 324

ftp_chdir 325

ftp_mkdir 325

ftp_rmdir 325

ftp_nlist 325

ftp_rawlist 325

ftp_systype 326

ftp_pasv 326

ftp_get 326

ftp_fget 326

ftp_put 327

ftp_fput 327

ftp_size 327

ftp_mdtm 327

ftp_rename 327

ftp_delete 328

ftp_quit 328

·网络函数库 328

fsockopen 328

pfsockopen 329

set_socket_blocking 329

gethostbyaddr 329

gethostbyname 330

gethostbynamel 330

checkdnsrr 331

getmxrr 331

openlog 331

syslog 332

closelog 332

debugger_on 332

debugger_off 332

·拼写检查函数库 333

aspell_new 333

aspell_check 333

aspell_check-raw 333

aspell_suggest 334

·BC高精确度函数库 334

bcadd 334

bccomp 334

bcdiv 335

bcmod 335

bcmul 335

bcpow 335

bcscale 336

bcsqrt 336

bcsub 336

·dBase格式表函数库 336

dbase_create 337

dbase_open 337

dbase_close 338

dbase_pack 338

dbase_add_record 338

dbase_delete_record 338

dbase_get_record 338

dbase_numfields 339

dbase_numrecords 339

·目录管理函数库 339

chdir 339

dir 340

closedir 340

opendir 340

readdir 341

rewinddir 341

·filePro数据库函数库 341

filepro 342

filepro_fieldname 342

filepro_fieldtype 342

filepro_fieldwidth 342

filepro_retrieve 342

filepro_fieldcount 343

filepro_rowcount 343

·HTTP相关函数库 343

header 343

setcookie 344

·电子邮件函数库 345

mail 345

·mhash哈希函数库 346

mhash_get_hash_name 346

mhash_get_block_size 347

mhash_count 347

mhash 347

·NIS函数库 348

yp_get_default_domain 348

yp_order 348

yp_master 349

yp_match 349

yp_first 349

yp_next 350

yp_errno 350

yp_err_string 351

·Perl相容语法函数库 351

preg_match 351

preg_match_all 352

preg_replace 353

preg_split 353

·正则表达式函数库 353

ereg 353

ereg_replace 354

eregi 354

eregi_replace 354

split 355

sql_regcase 355

·SNMP网管函数库 355

snmpget 355

snmpwalk 356

snmpwalkoid 356

snmp_get_quick_print 356

snmp_set_quick_print 357

·URL处理函数库 357

parse_url 357

urldecode 358

urlencode 358

base64_encode 358

base64_decode 358

·Session函数库 359

session_start 359

session_destroy 359

session_name 359

session_module_name 360

session_save_path 360

session_id 360

session_register 360

session_unregister 360

session_is_registered 361

session_decode 361

session_encode 361

·GNU记录函数库 361

recode_string 361

recode_file 361

·信号与共享内存函数库 362

sem_get 362

sem_acquire 362

sem_release 362

shm_attach 362

shm_detach 363

shm_remove 363

shm_put_var 363

shm_get_var 363

shm_remove_var 364

·压缩文件函数库 364

gzclose 364

gzeof 364

gzfile 364

gzgetc 364

gzgets 365

gzgetss 365

gzopen 365

gzpassthru 366

gzputs 366

gzread 366

gzrewind 366

gzseek 367

gztell 367

readgzfile 367

gzwrite 367

·XML解析函数库 368

xml_parser_create 368

xml_set_object 368

xml_set_element_handler 369

xml_set_character_data_handler 370

xml_set_processing_instruction_handler 370

xml_set_default_handler 371

xml_set_unparsed_entity_decl_handler 371

xml_set_notation_decl_handler 371

xml_set_external_entity_ref_handler 371

xml_parse 372

xml_get_error_code 372

xml_error_string 372

xml_get_current_line_number 372

xml_get_current_column_number 372

xml_get_current_byte_index 373

xml_parser_free 373

xml_parser_set_option 373

xml_parser_get_option 373

utf8_decode 373

utf8_encode 374