PHP ZIPARCHIVE 压缩文件处理目录结构

PHP ZIPARCHIVE 压缩文件处理目录结构 Prevent directory structure in compressed package

    $flag = $zip->open($filePath, \ZIPARCHIVE::CREATE);
    if ($flag!== TRUE) {
          //if Linux,need check file authorization
          exit("open file err="+$flag);
    }
    //add test.php to zip file 
    $zip->addFile('test.php');
    // run rename
    $zip->renameName('test.php','test.php');
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PHP官方手册中文版 PHP 手册 Mehdi Achour Friedhelm Betz Antony Dovgal Nuno Lopes Philip Olson Georg Richter Damien Seguy Jakub Vrana 编辑 Gabor Hojtsy 目录 前言 作者和贡献者 I. 入门指引 1. 简介 2. 简明教程 II. 安装与配置 3. 安装前需要考虑的事项 4. Unix 系统下的安装 5. Mac OS X 系统下的安装 6. Windows 系统下的安装 7. PECL 扩展库安装 8. 还有问题? 9. 运行时配置 III. 语言参考 10. 基本语法 11. 类型 12. 变量 13. 常量 14. 表达式 15. 运算符 16. 控制结构 17. 函数 18. 类与对象(PHP 4) 19. 类与对象(PHP 5) 20. Namespaces 21. 异常处理 22. 引用的解释 IV. 安全 23. 简介 24. 总则 25. 以 CGI 模式安装时 26. 以 Apache 模块安装时 27. 文件系统安全 28. 数据库安全 29. 错误报告 30. 使用 Register Globals 31. 用户提交的数据 32. 魔术引号 33. 隐藏 PHP 34. 保持更新 V. 特点 35. 用 PHP 进行 HTTP 认证 36. Cookie 37. 会话 38. 处理 XForms 39. 文件上传处理 40. 使用远程文件 41. 连接处理 42. 数据库永久连接 43. 安全模式 44. PHP 的命令行模式 VI. 函数参考 I. .NET 函数 II. Apache 特有函数 III. APC 可选 PHP 缓存 IV. APD 高级 PHP 调试器 V. Array 数组函数 VI. Aspell 函数(已废弃) VII. BBCode Functions VIII. BC math 高精度数学函数 IX. BCompiler PHP 字节码编译器 X. Bzip2 压缩函数 XI. Calendar 日历函数 XII. CCVS API 函数(已废弃) XIII. Classes/Objects 类/对象函数 XIV. Classkit 函数 XV. ClibPDF Functions [deprecated] XVI. COM 和 .Net(Windows)函数 XVII. Crack Functions XVIII. Character Type Functions XIX. CURL, Client URL Library Functions XX. Cybercash Payment Functions XXI. Credit Mutuel CyberMUT functions XXII. Cyrus IMAP administration Functions XXIII. Date/Time 日期/时间函数 XXIV. DB++ Functions XXV. Database (dbm-style) Abstraction Layer Functions XXVI. dBase Functions XXVII. DBM Functions [deprecated] XXVIII. dbx Functions XXIX. Direct IO Functions XXX. Directory 目录函数 XXXI. DOM Functions XXXII. DOM XML Functions XXXIII. enchant Functions XXXIV. Error Handling and Logging Functions XXXV. Exif Functions XXXVI. Expect Functions XXXVII. File Alteration Monitor Functions XXXVIII. Forms Data Format Functions XXXIX. Fileinfo Functions XL. filePro Functions XLI. Filesystem 文件系统函数 XLII. Filter Functions XLIII. Firebird/InterBase Functions XLIV. Firebird/Interbase Functions (PDO_FIREBIRD) XLV. FriBiDi Functions XLVI. FrontBase Functions XLVII. FTP 函数 XLVIII. Function Handling Functions XLIX. GeoIP Functions L. Gettext Functions LI. GMP Functions LII. gnupg 函数 LIII. Net_Gopher LIV. Haru PDF Functions LV. hash Functions LVI. HTTP 函数 LVII. Hyperwave Functions LVIII. Hyperwave API Functions LIX. i18n 函数 LX. IBM Functions (PDO_IBM) LXI. IBM DB2, Cloudscape and Apache Derby Functions LXII. iconv Functions LXIII. ID3 Functions LXIV. IIS Administration Functions LXV. Image 图像函数 LXVI. Imagick Image Library LXVII. IMAP, POP3 and NNTP Functions LXVIII. Informix Functions LXIX. Informix Functions (PDO_INFORMIX) LXX. Ingres II Functions LXXI. IRC Gateway Functions LXXII. PHP / Java Integration LXXIII. JSON 函数 LXXIV. KADM5 LXXV. LDAP Functions LXXVI. libxml Functions LXXVII. Lotus Notes Functions LXXVIII. LZF Functions LXXIX. Mail 邮件函数 LXXX. Mailparse Functions LXXXI. Math 数学函数 LXXXII. MaxDB PHP Extension LXXXIII. MCAL Functions LXXXIV. Mcrypt Encryption Functions LXXXV. MCVE (Monetra) Payment Functions LXXXVI. Memcache Functions LXXXVII. Mhash Functions LXXXVIII. Mimetype Functions LXXXIX. Ming functions for Flash XC. Miscellaneous Functions XCI. mnoGoSearch Functions XCII. Microsoft SQL Server Functions XCIII. Microsoft SQL Server and Sybase Functions (PDO_DBLIB) XCIV. Mohawk Software Session Handler Functions XCV. mSQL Functions XCVI. Multibyte String Functions XCVII. muscat Functions XCVIII. MySQL 函数 XCIX. MySQL Functions (PDO_MYSQL) C. MySQLi 扩展库 CI. Ncurses Terminal Screen Control Functions CII. Network Functions CIII. Newt Functions CIV. NSAPI-specific Functions CV. Object Aggregation/Composition Functions CVI. Object property and method call overloading CVII. Oracle 函数 CVIII. ODBC Functions (Unified) CIX. ODBC and DB2 Functions (PDO_ODBC) CX. oggvorbis CXI. OpenAL Audio Bindings CXII. OpenSSL Functions CXIII. Oracle 函数(已废弃) CXIV. Oracle Functions (PDO_OCI) CXV. Output Control 输出控制函数 CXVI. Ovrimos SQL Functions CXVII. Paradox File Access CXVIII. Parsekit Functions CXIX. Process Control Functions CXX. Perl 兼容正则表达式函数 CXXI. PDF 函数 CXXII. PDO Functions CXXIII. Phar archive stream and classes CXXIV. PHP Options&Information CXXV. POSIX Functions CXXVI. POSIX 扩展正则表达式函数 CXXVII. PostgreSQL 数据库函数 CXXVIII. PostgreSQL Functions (PDO_PGSQL) CXXIX. Printer Functions CXXX. Program Execution Functions CXXXI. PostScript document creation CXXXII. Pspell Functions CXXXIII. qtdom Functions CXXXIV. Radius CXXXV. Rar Functions CXXXVI. GNU Readline CXXXVII. GNU Recode Functions CXXXVIII. RPM Header Reading 函数 CXXXIX. runkit Functions CXL. SAM - Simple Asynchronous Messaging CXLI. Satellite CORBA client extension [deprecated] CXLII. SCA Functions CXLIII. SDO Functions CXLIV. SDO XML Data Access Service Functions CXLV. SDO Relational Data Access Service Functions CXLVI. Semaphore, Shared Memory and IPC Functions CXLVII. SESAM Database Functions CXLVIII. PostgreSQL Session Save Handler CXLIX. Session 会话处理函数 CL. Shared Memory Functions CLI. SimpleXML functions CLII. SNMP 函数 CLIII. SOAP Functions CLIV. Socket Functions CLV. Standard PHP Library (SPL) Functions CLVI. SQLite Functions CLVII. SQLite Functions (PDO_SQLITE) CLVIII. Secure Shell2 Functions CLIX. Statistics Functions CLX. Stream Functions CLXI. String 字符串处理函数 CLXII. Subversion 函数 CLXIII. Shockwave Flash Functions CLXIV. Swish Functions CLXV. Sybase Functions CLXVI. TCP Wrappers Functions CLXVII. Tidy Functions CLXVIII. Tokenizer Functions CLXIX. Unicode Functions CLXX. URL 函数 CLXXI. Variable 变量函数 CLXXII. Verisign Payflow Pro Functions CLXXIII. vpopmail Functions CLXXIV. W32api 函数 CLXXV. WDDX Functions CLXXVI. win32ps Functions CLXXVII. win32service Functions CLXXVIII. xattr Functions CLXXIX. xdiff Functions CLXXX. XML 语法解析函数 CLXXXI. XML-RPC 函数 CLXXXII. XMLReader functions CLXXXIII. XMLWriter Functions CLXXXIV. XSL functions CLXXXV. XSLT Functions CLXXXVI. YAZ Functions CLXXXVII. YP/NIS Functions CLXXXVIII. Zip File Functions CLXXXIX. Zlib Compression Functions VII. PHP at the Core: A Hacker's Guide to the Zend Engine 45. The PHP 5 build system 46. Extension structure 47. Memory management 48. Working with variables 49. Writing functions 50. Working with classes and objects 51. Working with resources 52. Working with INI settings 53. Working with streams 54. PDO Driver How-To 55. Extension FAQs 56. Zend Engine 2 API reference 57. Zend Engine 1 58. The future: PHP 6 and Zend Engine 3 VIII. FAQ:常见问题 59. 一般信息 60. 邮件列表 61. 获取 PHP 62. 数据库问题 63. 安装常见问题 64. 编译问题 65. 使用 PHP 66. PHP 和 HTML 67. PHP 和 COM 68. PHP 和其它语言 69. 从 PHP/FI 2 移植到 PHP 3 70. 从 PHP 3 移植到 PHP 4 71. 从 PHP 4 移植到 PHP 5 72. 杂类问题 IX. 附录 A. PHP 及其相关工程的历史 B. Migrating from PHP 5.1.x to PHP 5.2.x C. Migrating from PHP 5.0.x to PHP 5.1.x D. 从 PHP 4 移植到 PHP 5 E. 从 PHP 3 移植到 PHP 4 F. 从 PHP/FI 2 移植到 PHP 3 G. PHP 的调试 H. 配置选项 I. php.ini 配置选项 J. 所支持时区列表 K. 扩展库分类 L. 函数别名列表 M. 保留字列表 N. 资源类型列表 O. 支持的协议/封装协议列表 P. 可用过滤器列表 Q. 所支持的套接字传输器(Socket Transports)列表 R. PHP 类型比较表 S. 解析器代号列表 T. Userland Naming Guide U. 关于本手册 V. 开放出版许可协议 W. 函数索引 X. 补充说明 X. CHM 版本 73. 关于此版本 74. Using PHP Manual CHM Edition 75. The Full Text Search 76. Specialities of this Edition 77. Integrating the PHP Manual 78. Skin development 79. CHM Edition Credits
PHP5 完整官方 中文教程 版权信息 前言 入门指引 简介 简明教程 安装与配置 安装前需要考虑的事项 Unix 系统下的安装 Mac OS X 系统下的安装 Windows 系统下的安装 PECL 扩展库安装 还有问题? 运行时配置 语言参考 基本语法 类型 变量 常量 表达式 运算符 控制结构 函数 类与对象(PHP 4) 类与对象(PHP 5) Namespaces 异常处理 引用的解释 安全 简介 总则 以 CGI 模式安装时 以 Apache 模块安装时 文件系统安全 数据库安全 错误报告 使用 Register Globals 用户提交的数据 魔术引号 隐藏 PHP 保持更新 特点 用 PHP 进行 HTTP 认证 Cookie 会话 处理 XForms 文件上传处理 使用远程文件 连接处理 数据库永久连接 安全模式 PHP 的命令行模式 函数参考 .NET — .NET 函数 Apache — Apache 特有函数 APC — APC 可选 PHP 缓存 APD — APD 高级 PHP 调试器 Arrays — Array 数组函数 Aspell — Aspell 函数(已废弃) BBCode — BBCode Functions BC math — BC math 高精度数学函数 bcompiler — BCompiler PHP 字节码编译器 Bzip2 — Bzip2 压缩函数 Calendar — Calendar 日历函数 CCVS — CCVS API 函数(已废弃) Classes/Objects — Classes/Objects 类/对象函数 Classkit — Classkit 函数 ClibPDF — ClibPDF Functions [deprecated] COM — COM 和 .Net(Windows)函数 Crack — Crack Functions ctype — Character Type Functions CURL — CURL, Client URL Library Functions Cybercash — Cybercash Payment Functions CyberMUT — Credit Mutuel CyberMUT functions Cyrus IMAP — Cyrus IMAP administration Functions Date/Time — Date/Time 日期/时间函数 DB++ — DB++ Functions dba — Database (dbm-style) Abstraction Layer Functions dBase — dBase Functions DBM — DBM Functions [deprecated] dbx — dbx Functions Direct IO — Direct IO Functions Directories — Directory 目录函数 DOM — DOM Functions DOM XML — DOM XML Functions enchant — enchant Functions Errors and Logging — Error Handling and Logging Functions Exif — Exif Functions Expect — Expect Functions fam — File Alteration Monitor Functions FDF — Forms Data Format Functions Fileinfo — Fileinfo Functions filePro — filePro Functions Filesystem — Filesystem 文件系统函数 Filter — Filter Functions Firebird/InterBase — Firebird/InterBase Functions Firebird/Interbase (PDO) — Firebird/Interbase Functions (PDO_FIREBIRD) FriBiDi — FriBiDi Functions FrontBase — FrontBase Functions FTP — FTP 函数 Function handling — Function Handling Functions GeoIP — GeoIP Functions gettext — Gettext Functions GMP — GMP Functions gnupg — gnupg 函数 gopher — Net_Gopher haru — Haru PDF Functions hash — hash Functions HTTP — HTTP 函数 Hyperwave — Hyperwave Functions Hyperwave API — Hyperwave API Functions i18n — i18n 函数 IBM (PDO) — IBM Functions (PDO_IBM) ibm_db2 — IBM DB2, Cloudscape and Apache Derby Functions iconv — iconv Functions id3 — ID3 Functions IIS Functions — IIS Administration Functions Image — Image 图像函数 Imagick Image Library IMAP — IMAP, POP3 and NNTP Functions Informix — Informix Functions Informix (PDO) — Informix Functions (PDO_INFORMIX) Ingres II — Ingres II Functions IRC Gateway — IRC Gateway Functions Java — PHP / Java Integration JSON — JSON 函数 kadm5 — KADM5 LDAP — LDAP Functions libxml — libxml Functions Lotus Notes — Lotus Notes Functions LZF — LZF Functions Mail — Mail 邮件函数 Mailparse — Mailparse Functions Math — Math 数学函数 MaxDB — MaxDB PHP Extension MCAL — MCAL Functions mcrypt — Mcrypt Encryption Functions MCVE — MCVE (Monetra) Payment Functions Memcache — Memcache Functions mhash — Mhash Functions Mimetype — Mimetype Functions Ming (flash) — Ming functions for Flash Misc. — Miscellaneous Functions mnoGoSearch — mnoGoSearch Functions MS SQL Server — Microsoft SQL Server Functions MS SQL Server (PDO) — Microsoft SQL Server and Sybase Functions (PDO_DBLIB) Msession — Mohawk Software Session Handler Functions mSQL — mSQL Functions Multibyte String — Multibyte String Functions muscat — muscat Functions MySQL — MySQL 函数 MySQL (PDO) — MySQL Functions (PDO_MYSQL) mysqli — MySQLi 扩展库 Ncurses — Ncurses Terminal Screen Control Functions Network — Network Functions Newt — Newt Functions NSAPI — NSAPI-specific Functions Object Aggregation — Object Aggregation/Composition Functions Object overloading — Object property and method call overloading OCI8 — Oracle 函数 ODBC — ODBC Functions (Unified) ODBC and DB2 (PDO) — ODBC and DB2 Functions (PDO_ODBC) OGG/Vorbis — oggvorbis openal — OpenAL Audio Bindings OpenSSL — OpenSSL Functions Oracle — Oracle 函数(已废弃) Oracle (PDO) — Oracle Functions (PDO_OCI) Output Control — Output Control 输出控制函数 OvrimosSQL — Ovrimos SQL Functions Paradox — Paradox File Access Parsekit — Parsekit Functions PCNTL — Process Control Functions PCRE — Perl 兼容正则表达式函数 PDF — PDF 函数 PDO — PDO Functions phar — Phar archive stream and classes PHP Options/Info — PHP Options&Information POSIX — POSIX Functions POSIX Regex — POSIX 扩展正则表达式函数 PostgreSQL — PostgreSQL 数据库函数 PostgreSQL (PDO) — PostgreSQL Functions (PDO_PGSQL) Printer — Printer Functions Program Execution — Program Execution Functions PS — PostScript document creation Pspell — Pspell Functions qtdom — qtdom Functions radius — Radius Rar — Rar Functions Readline — GNU Readline Recode — GNU Recode Functions RPMReader — RPM Header Reading 函数 runkit — runkit Functions SAM — SAM - Simple Asynchronous Messaging Satellite — Satellite CORBA client extension [deprecated] SCA — SCA Functions SDO — SDO Functions SDO DAS XML — SDO XML Data Access Service Functions SDO-DAS-Relational — SDO Relational Data Access Service Functions Semaphore — Semaphore, Shared Memory and IPC Functions SESAM — SESAM Database Functions Session PgSQL — PostgreSQL Session Save Handler Sessions — Session 会话处理函数 shmop — Shared Memory Functions SimpleXML — SimpleXML functions SNMP — SNMP 函数 SOAP — SOAP Functions Sockets — Socket Functions spl — Standard PHP Library (SPL) Functions SQLite — SQLite Functions SQLite (PDO) — SQLite Functions (PDO_SQLITE) ssh2 — Secure Shell2 Functions Statistics — Statistics Functions Streams — Stream Functions Strings — String 字符串处理函数 SVN — Subversion 函数 SWF — Shockwave Flash Functions swish — Swish Functions Sybase — Sybase Functions TCP Wrappers — TCP Wrappers Functions tidy — Tidy Functions Tokenizer — Tokenizer Functions Unicode — Unicode Functions URLs — URL 函数 Variables — Variable 变量函数 Verisign Payflow Pro — Verisign Payflow Pro Functions vpopmail — vpopmail Functions W32api — W32api 函数 WDDX — WDDX Functions win32ps — win32ps Functions win32service — win32service Functions xattr — xattr Functions xdiff — xdiff Functions XML — XML 语法解析函数 XML-RPC — XML-RPC 函数 XMLReader — XMLReader functions XMLWriter — XMLWriter Functions XSL — XSL functions XSLT — XSLT Functions YAZ — YAZ Functions YP/NIS — YP/NIS Functions Zip — Zip File Functions Zlib — Zlib Compression Functions PHP at the Core: A Hacker's Guide to the Zend Engine The PHP 5 build system Extension structure Memory management Working with variables Writing functions Working with classes and objects Working with resources Working with INI settings Working with streams PDO Driver How-To Extension FAQs Zend Engine 2 API reference Zend Engine 1 The future: PHP 6 and Zend Engine 3 FAQ — FAQ:常见问题 一般信息 邮件列表 获取 PHP 数据库问题 安装 — 安装常见问题 编译问题 使用 PHP PHP 和 HTML PHP 和 COM PHP 和其它语言PHP/FI 2 移植到 PHP 3 从 PHP 3 移植到 PHP 4 从 PHP 4 移植到 PHP 5 杂类问题 附录 PHP 及其相关工程的历史 Migrating from PHP 5.1.x to PHP 5.2.x Migrating from PHP 5.0.x to PHP 5.1.x 从 PHP 4 移植到 PHP 5 从 PHP 3 移植到 PHP 4 从 PHP/FI 2 移植到 PHP 3 PHP 的调试 配置选项 php.ini 配置选项 所支持时区列表 扩展库分类 函数别名列表 保留字列表 资源类型列表 支持的协议/封装协议列表 可用过滤器列表 所支持的套接字传输器(Socket Transports)列表 PHP 类型比较表 解析器代号列表 Userland Naming Guide 关于本手册 开放出版许可协议 函数索引 补充说明
PHP 手册 Mehdi Achour Friedhelm Betz Antony Dovgal Nuno Lopes Hannes Magnusson Georg Richter Damien Seguy Jakub Vrana 其他贡献者 2007-12-10 Philip Olson 中文翻译人员: 王远之 肖理达 肖盛文 黄啸宇 宋琪 陈伯乐 刘铭 © 1997-2007 PHP 文档组 版权信息 前言 入门指引 简介 简明教程 安装与配置 安装前需要考虑的事项 Unix 系统下的安装 Mac OS X 系统下的安装 Windows 系统下的安装 PECL 扩展库安装 还有问题? 运行时配置 语言参考 基本语法 类型 变量 常量 表达式 运算符 控制结构 函数 类与对象(PHP 4) 类与对象(PHP 5) Namespaces 异常处理 引用的解释 安全 简介 总则 以 CGI 模式安装时 以 Apache 模块安装时 文件系统安全 数据库安全 错误报告 使用 Register Globals 用户提交的数据 魔术引号 隐藏 PHP 保持更新 特点 用 PHP 进行 HTTP 认证 Cookie 会话 处理 XForms 文件上传处理 使用远程文件 连接处理 数据库永久连接 安全模式 PHP 的命令行模式 函数参考 .NET — .NET 函数 Apache — Apache 特有函数 APC — APC 可选 PHP 缓存 APD — APD 高级 PHP 调试器 Arrays — Array 数组函数 Aspell — Aspell 函数(已废弃) BBCode — BBCode Functions BC math — BC math 高精度数学函数 bcompiler — BCompiler PHP 字节码编译器 Bzip2 — Bzip2 压缩函数 Calendar — Calendar 日历函数 CCVS — CCVS API 函数(已废弃) Classes/Objects — Classes/Objects 类/对象函数 Classkit — Classkit 函数 ClibPDF — ClibPDF Functions [deprecated] COM — COM 和 .Net(Windows)函数 Crack — Crack Functions ctype — Character Type Functions CURL — CURL, Client URL Library Functions Cybercash — Cybercash Payment Functions CyberMUT — Credit Mutuel CyberMUT functions Cyrus IMAP — Cyrus IMAP administration Functions Date/Time — Date/Time 日期/时间函数 DB++ — DB++ Functions dba — Database (dbm-style) Abstraction Layer Functions dBase — dBase Functions DBM — DBM Functions [deprecated] dbx — dbx Functions Direct IO — Direct IO Functions Directories — Directory 目录函数 DOM — DOM Functions DOM XML — DOM XML Functions enchant — enchant Functions Errors and Logging — Error Handling and Logging Functions Exif — Exif Functions Expect — Expect Functions fam — File Alteration Monitor Functions FDF — Forms Data Format Functions Fileinfo — Fileinfo Functions filePro — filePro Functions Filesystem — Filesystem 文件系统函数 Filter — Filter Functions Firebird/InterBase — Firebird/InterBase Functions Firebird/Interbase (PDO) — Firebird/Interbase Functions (PDO_FIREBIRD) FriBiDi — FriBiDi Functions FrontBase — FrontBase Functions FTP — FTP 函数 Function handling — Function Handling Functions GeoIP — GeoIP Functions gettext — Gettext Functions GMP — GMP Functions gnupg — gnupg 函数 gopher — Net_Gopher haru — Haru PDF Functions hash — hash Functions HTTP — HTTP 函数 Hyperwave — Hyperwave Functions Hyperwave API — Hyperwave API Functions i18n — i18n 函数 IBM (PDO) — IBM Functions (PDO_IBM) ibm_db2 — IBM DB2, Cloudscape and Apache Derby Functions iconv — iconv Functions id3 — ID3 Functions IIS Functions — IIS Administration Functions Image — Image 图像函数 Imagick Image Library IMAP — IMAP, POP3 and NNTP Functions Informix — Informix Functions Informix (PDO) — Informix Functions (PDO_INFORMIX) Ingres II — Ingres II Functions IRC Gateway — IRC Gateway Functions Java — PHP / Java Integration JSON — JSON 函数 kadm5 — KADM5 LDAP — LDAP Functions libxml — libxml Functions Lotus Notes — Lotus Notes Functions LZF — LZF Functions Mail — Mail 邮件函数 Mailparse — Mailparse Functions Math — Math 数学函数 MaxDB — MaxDB PHP Extension MCAL — MCAL Functions mcrypt — Mcrypt Encryption Functions MCVE — MCVE (Monetra) Payment Functions Memcache — Memcache Functions mhash — Mhash Functions Mimetype — Mimetype Functions Ming (flash) — Ming functions for Flash Misc. — Miscellaneous Functions mnoGoSearch — mnoGoSearch Functions MS SQL Server — Microsoft SQL Server Functions MS SQL Server (PDO) — Microsoft SQL Server and Sybase Functions (PDO_DBLIB) Msession — Mohawk Software Session Handler Functions mSQL — mSQL Functions Multibyte String — Multibyte String Functions muscat — muscat Functions MySQL — MySQL 函数 MySQL (PDO) — MySQL Functions (PDO_MYSQL) mysqli — MySQLi 扩展库 Ncurses — Ncurses Terminal Screen Control Functions Network — Network Functions Newt — Newt Functions NSAPI — NSAPI-specific Functions Object Aggregation — Object Aggregation/Composition Functions Object overloading — Object property and method call overloading OCI8 — Oracle 函数 ODBC — ODBC Functions (Unified) ODBC and DB2 (PDO) — ODBC and DB2 Functions (PDO_ODBC) OGG/Vorbis — oggvorbis openal — OpenAL Audio Bindings OpenSSL — OpenSSL Functions Oracle — Oracle 函数(已废弃) Oracle (PDO) — Oracle Functions (PDO_OCI) Output Control — Output Control 输出控制函数 OvrimosSQL — Ovrimos SQL Functions Paradox — Paradox File Access Parsekit — Parsekit Functions PCNTL — Process Control Functions PCRE — Perl 兼容正则表达式函数 PDF — PDF 函数 PDO — PDO Functions phar — Phar archive stream and classes PHP Options/Info — PHP Options&Information POSIX — POSIX Functions POSIX Regex — POSIX 扩展正则表达式函数 PostgreSQL — PostgreSQL 数据库函数 PostgreSQL (PDO) — PostgreSQL Functions (PDO_PGSQL) Printer — Printer Functions Program Execution — Program Execution Functions PS — PostScript document creation Pspell — Pspell Functions qtdom — qtdom Functions radius — Radius Rar — Rar Functions Readline — GNU Readline Recode — GNU Recode Functions RPMReader — RPM Header Reading 函数 runkit — runkit Functions SAM — SAM - Simple Asynchronous Messaging Satellite — Satellite CORBA client extension [deprecated] SCA — SCA Functions SDO — SDO Functions SDO DAS XML — SDO XML Data Access Service Functions SDO-DAS-Relational — SDO Relational Data Access Service Functions Semaphore — Semaphore, Shared Memory and IPC Functions SESAM — SESAM Database Functions Session PgSQL — PostgreSQL Session Save Handler Sessions — Session 会话处理函数 shmop — Shared Memory Functions SimpleXML — SimpleXML functions SNMP — SNMP 函数 SOAP — SOAP Functions Sockets — Socket Functions SPL — Standard PHP Library (SPL) Functions SQLite — SQLite Functions SQLite (PDO) — SQLite Functions (PDO_SQLITE) ssh2 — Secure Shell2 Functions Statistics — Statistics Functions Streams — Stream Functions Strings — String 字符串处理函数 SVN — Subversion 函数 SWF — Shockwave Flash Functions swish — Swish Functions Sybase — Sybase Functions TCP Wrappers — TCP Wrappers Functions tidy — Tidy Functions Tokenizer — Tokenizer Functions Unicode — Unicode Functions URLs — URL 函数 Variables — Variable 变量函数 Verisign Payflow Pro — Verisign Payflow Pro Functions vpopmail — vpopmail Functions W32api — W32api 函数 WDDX — WDDX Functions win32ps — win32ps Functions win32service — win32service Functions xattr — xattr Functions xdiff — xdiff Functions XML — XML 语法解析函数 XML-RPC — XML-RPC 函数 XMLReader — XMLReader functions XMLWriter — XMLWriter Functions XSL — XSL functions XSLT — XSLT Functions YAZ — YAZ Functions YP/NIS — YP/NIS Functions Zip — Zip File Functions Zlib — Zlib Compression Functions PHP at the Core: A Hacker's Guide to the Zend Engine The PHP 5 build system Extension structure Memory management Working with variables Writing functions Working with classes and objects Working with resources Working with INI settings Working with streams PDO Driver How-To Extension FAQs Zend Engine 2 API reference Zend Engine 1 The future: PHP 6 and Zend Engine 3 FAQ — FAQ:常见问题 一般信息 邮件列表 获取 PHP 数据库问题 安装 — 安装常见问题 编译问题 使用 PHP PHP 和 HTML PHP 和 COM PHP 和其它语言PHP/FI 2 移植到 PHP 3 从 PHP 3 移植到 PHP 4 从 PHP 4 移植到 PHP 5 杂类问题 附录 PHP 及其相关工程的历史 Migrating from PHP 5.1.x to PHP 5.2.x Migrating from PHP 5.0.x to PHP 5.1.x 从 PHP 4 移植到 PHP 5 从 PHP 3 移植到 PHP 4 从 PHP/FI 2 移植到 PHP 3 PHP 的调试 配置选项 php.ini 配置选项 所支持时区列表 扩展库分类 函数别名列表 保留字列表 资源类型列表 支持的协议/封装协议列表 可用过滤器列表 所支持的套接字传输器(Socket Transports)列表 PHP 类型比较表 解析器代号列表 Userland Naming Guide 关于本手册 开放出版许可协议 函数索引 补充说明
大多数PHPer都想写出运行状态良好的应用程序,而且希望尽可能做得简单且不费事。这篇文章是有关 CodeIgniter 的(以下简称 CI),CI 是一个达成以上目标的框架。 如果你只是要达成一个最终的结果,而把中间所有的编码细节和复杂统统丢给一个框架,CI 是你最好的朋友。 CI 有很多优点:免费,轻量级,容易安装,它能使你的编程生涯变得很轻松。 这一章我们会告诉你: CI 能为你做什么? 什么是“框架”?CI 为什么能被称为框架? “开源”商业模式。 CI 的某些不足(是的,它并不完美)。 1.1 CodeIgniter 能为你做什么? 如果你已经是一位 PHPer,开发PHP 应用,CodeIgniter 将会帮助你做得更好,更容易达成目标。CI 会减少你的代码量。你的脚本可读性也会更好,更容易升级。它会使你的网站结构更紧凑,代码更强健,如果没有很好地研究 CI 的源代码,你可能还无法察觉到它的强健。 对大多数兄弟来讲,你可能已经花了不少时间,系统地学习了 PHP、HTML 和 CSS,当然还有 MySQL 什么的,不过如果使用 CI,你只需要一些基本的 LAMP(WAMP)知识,你没有必要先成为一个专家才能使用 CI。你完全可以先借助于 CI 或别的什么框架软件,成为一个有生产力的 PHP 程序员,拿着高薪然后优雅地进一步学习 PHP 的中高级知识,直至成为一位真正的 PHP 骨灰级的人物。 下述情形,你最好不要使用CI: 你没有一点PHP和HTML的基本知识。 你想用最少的代码,快速简便的写一个基本的内容管理系统(CMS)(可以看看Expression Engine)。 你想写一个只有几个标准特性的简单的网站。 1.1.1 节省时间 CI 学习周期短,见效快。让我们试着评估一下相关的要素: CI 如何减少代码量? 你真的可以减少很多工作量:敲击键盘的次数减少了,代码错误减少了,你只需要很少的时间调试代码。代码量减少还意味着你只需要较少的空间来存放应用程序。 举两个例子(稍后它们会被进一步分析,因此不用担心如何了解它们的工作原理!) 想象你正在写一个 MySQL 数据库查询。可能的代码如下: 复制代码到剪贴板PHP 代码$connection = mysql_connect("localhost","fred","12345"); mysql_select_db("websites", $connection); $result = mysql_query ("SELECT * FROM sites", $connection); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { foreach ($row as $attribute) print "{$attribute[1]} "; }现在看看 CI 如何处理同一个问题: 复制代码到剪贴板PHP 代码$this->load->database('websites'); $query = $this->db->get('sites'); foreach ($query->result() as $row) { print $row->url; }比较字符数:前者 336,后者 112。 第二个例子,现在让我们想象你正在用 HTML 写一个数据输入窗口,你想要一个下拉输入框。下拉框中有三个选项。代码如下: 复制代码到剪贴板HTML 代码<select name="type"> <option value="1">www.this.com</option> <option value="2">www.that.com</option> <option value="3" selected>www.theother.com</option> </select>CI 的写法和前例一样,因为它把相关内容放入一个数组,更容易由 PHP 进行处理: 复制代码到剪贴板PHP 代码$urlarray = array( '1' => 'www.this.com', '2' => 'www.that.com', '3' => 'www.theother.com', ); $variable .= form_dropdown('url', $urlarray, '3');在 HTML 中,你需要输入 154 个字符;在 CI 中,只需要 128 个字符。 1.1.2 使你的网站更健壮 你不需要写很多代码,是因为 CI 提供了许多标准的功能,这些经过仔细推敲的框架内的代码,对安全性和输入进行了有效的校验和考虑。初学者往往没有足够的能力全面兼顾功能和安全。(这也是中高级程序员与新手之间能力差异的一个方面) 1.1.2.1 确保你的链接自动更新 设想你正在编写一个菜单页面,有许多超链接可重定向到其他页面。他们全部以传统的 HTML 格式编写: 复制代码到剪贴板HTML 代码<a href="http://www.mysite.com/index.php/start/hello/fred">say hello to Fred</a>后来,你决定转移网站到其他 URL。这意谓你必须仔细地去查找并修改代码中的每一处 URL,否则它们将无法正常工作。 CI 给你一个简单的函数,可以这样编写超链接: 复制代码到剪贴板PHP 代码echo anchor('start/hello/fred', 'Say hello to Fred');CI 推荐你把你的 URL 放入一个配置文件中供你的脚本读取。CI 的 anchor 函数会自动从配置文件中提取相关 URL。因此,当你修改一个 URL 时,你只需要修改配置文件中的对应链接,然后所有超链接将自动更新。 1.1.2.2 防止对数据库的攻击:对表单输入的数据进行校验和处理 数据输入可能引发许多问题。因为 HTML 和数据库的限制,数据中总包含特定的符号—举例来说,省略符号和引号—可能导致你的数据库遭到攻击,最终得到你无法预料的结果。 解决方案是在把这些数据存入数据库前对这些数据进行相关处理。这样做会浪费一些系统时间,增加一些额外编码。 CI 的表单辅助函数会自动地完成这些工作。因此,当你编写一个输入框时: 复制代码到剪贴板PHP 代码echo form_input('username', 'johndoe');CI 也隐式地执行下列校验函数: 复制代码到剪贴板PHP 代码function form_prep($str = '') { if ($str === '') { return ''; } $temp = '__TEMP_AMPERSANDS__'; // Replace entities to temporary markers so that // htmlspecialchars won't mess them up $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str); $str = preg_replace("/&(\w+);/", "$temp\\1;", $str); $str = htmlspecialchars($str); // In case htmlspecialchars misses these. $str = str_replace(array("'", '"'), array("'", """), $str); // Decode the temp markers back to entities $str = preg_replace("/$temp(\d+);/","&#\\1;",$str); $str = preg_replace("/$temp(\w+);/","&\\1;",$str); return $str; }上述函数捕获像“&”这样的特殊字符,以便在你的页面提交时不会造成混乱。你应该知道,有些字符会引起问题。 并不是所有的用户都会中规中矩的输入符合要求的信息,你也不可能知道使用浏览器输入信息的是什么人,他们在想什么,做什么。你可以使用 CI 来防止输入不符合要求的信息。当然,你大可不必知道 CI 是如何在幕后为你做到这一切的,你只需要简单地输入如下代码: 复制代码到剪贴板PHP 代码echo form_input('username', 'johndoe');1.1.3 增强你的代码 CI 使你写代码更容易了。不像有些类库如 PEAR 等,集成比较困难,(有时候你会找不到支持 PEAR 的空间),CI 很容易集成,只要把它放入一个目录,它就能很好地工作。CI 所有代码的可读性好,也很健壮,推出前经过社区用户的认真测试,所以在你可以使用时,这些代码已经经历了很多考验。 让我们看两个例子。 1.1.3.1 发送 Email 和附件很简单 发送 Email 的功能实现起来比较复杂,但是,使用 CI 将使这件事变得很简单: 复制代码到剪贴板PHP 代码$this->load->library('email'); $this->email->from('[email protected]', 'Your Name'); $this->email->subject('Email Test'); $this->email->message('Testing the email class.'); $this->email->send();实现发送 Email 的功能中有一些不容易解决的技术问题:比如设置文本自动换行(取消设置的话则可以保持长 URL 地址不被换行或截断)或发送附件。标准的 PHP 实现起来比较复杂,CI 简化了这些工作,它的 Email 类使得发送附件很简单: 复制代码到剪贴板PHP 代码$this->email->attach('/path/to/photo1.jpg');CI 把内部的复杂部分悄悄地完成了,举例来说,实现了列举近百种不同附件的 MIME 类型的功能。所以它知道你的相片 photo1.jpg 是一个“image/jpeg”MIME 类型。因此它在你附件的适当位置填写必要的限制符号,它处理文本的换行,让你轻松标记出不希望出现换行的文本块。 1.1.3.2 压缩用户要下载的文件以加快下载速度 为了加快下载速度,常见的做法是在下载之前压缩下载文件。你可能不知道如何处理。但 CI 可以方便地让你用 4 行代码完成此功能: 复制代码到剪贴板PHP 代码$name = 'mydata1.txt'; $data = 'the contents of my file..........'; $this->zip->add_data($name, $data); $this->zip->archive('c:/my_backup.zip');运行这些代码,你会在你的 C 盘根目录下找到一个压缩文件,解压后即为原始文件。 你网站的用户并不清楚你是如何简便实现这个功能的,但他们能体会到你的网站的下载速度很快,而你只用了数分种(而不是数小时)就实现了这个功能。 1.2 CodeIgniter 是什么?框架又是什么? 当发明计算机编程不久之后,便有人发现,这其中涉及到了太多的重复操作。之后,也许是 Ada Lovelace(人类历史上的首位程序员),又或许是 Alan Turning,决定将计算机程序模块化,从而使得片段程序代码可以重复使用。PHP 程序员们早已习惯了将需要重复使用的代码写在函数中,并将这些函数放在 include 文件里。 同样的,框架是为重用而发明的,存放在独立的文件中,用来简化重复操作的代码。 上面例子中连接数据库和编写 HTML 表单元素的工作都可以调用相关的 CI 函数来进行简化。 它超越了这一点。有很多种方法实现同样的功能;大多数的框架会让你按照它实现的方法来做。他们选择了一种方式来解决问题,所以你也必须要遵循这种方式。如果方式得当,编程便会轻松许多,反之则会事倍功半。 好的框架设计能实现需要的功能,而且尽可能地不互相牵连。一个好框架为你做出各种功能的实现,并且给你提供一步一步的编程指导。 提到框架时,就不能不提到著名的框架:Ruby on Rails。 Rails 做得相当成功,因为它籍由最少量的编码,提供简便快速的网站开发。本质上,它是一个结构和一组工具,专为使用 Ruby 语言的用户开发,允许你快速建立 Ruby 系统原型。它不是 Ruby 语言中唯一的框架,但它一定是最有开发效率和最有名的。另一方面,如果你已经花了很大功夫学习 PHP 的话,那么从 Ruby 重新开始又要重头学起。 为 PHP 开发的框架有很多个(大约 40 个),CI 只是其中之一。其它的还包括 Zend Framework、Cake、Trax 等。下列网址可以找到一个针对十种框架的简明图表分析:http://www.phpit.net/article/ten-different-php-frameworks/。 如果你访问上述网址中相关产品的官方网站,你将会注意到,每个论坛都有一个共同的热点,就是到底哪一个框架是最好的?事实似乎是每个都有它的长处,而且又都有自己的弱点。我的评估标准是:我很忙;因此框架应该节省我的时间,从中选择一个后,就坚持使用下去,因此就有了这本介绍 CI 的书。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值