Core PHP programming

811 3.3K 0
Core PHP programming

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Tài liệu về học lập trình web bằng ngôn ngữ PHP cho tất cả mọi người.

Table of Contents 1Main Page 2Table of content 7Copyright 9Praise for 'Core PHP Programming' 12Prentice Hall PTR Core Series 13About Prentice Hall Professional Technical Reference 14Foreword 15Preface 17Acknowledgments 18Part I: Programming with PHP 19 Chapter 1. An Introduction to PHP 20 1.1 The Origins of PHP 22 1.2 PHP Is Better Than Its Alternatives 23 1.3 Interfaces to External Systems 24 1.4 How PHP Works with the Web Server 25 1.5 Hardware and Software Requirements 29 1.6 What a PHP Script Looks Like 31 1.7 Saving Data for Later 33 1.8 Receiving User Input 35 1.9 Choosing Between Alternatives 36 1.10 Repeating Code 38 Chapter 2. Variables, Operators, and Expressions 39 2.1 A Top-Down View 41 2.2 Data Types 44 2.3 Variables 48 2.4 Constants 49 2.5 Operators 59 2.6 Building Expressions 61 Chapter 3. Control Statements 62 3.1 The 'if' Statement 64 3.2 The '?' Operator 65 3.3 The 'switch' Statement 67 3.4 Loops 72 3.5 'exit', 'die', and 'return' 73 3.6 Exceptions 75 3.7 Declare 76 Chapter 4. Functions 77 4.1 Declaring a Function 78 4.2 The 'return' Statement 80 4.3 Scope 82 4.4 Static Variables 83 4.5 Arguments 85 4.6 Recursion 87 4.7 Dynamic Function Calls 88 Chapter 5. Arrays 89 5.1 Single-Dimensional Arrays 90 5.2 Indexing Arrays 91 5.3 Initializing Arrays 92 5.4 Multidimensional Arrays 93 5.5 Casting Arrays 95 5.6 The '+' Operator 96 5.7 Referencing Arrays Inside Strings 97 Chapter 6. Classes and Objects 98 6.1 Object-Oriented Programming 99 6.2 The PHP 5 Object Model 100 6.3 Defining a Class 102 6.4 Constructors and Destructors 104 6.5 Cloning 106 6.6 Accessing Properties and Methods 108 6.7 Static Class Members 110 6.8 Access Types 113 6.9 Binding 116 6.10 Abstract Methods and Abstract Classes 119 6.11 User-Level Overloading 121 6.12 Class Autoloading 122 6.13 Object Serialization 124 6.14 Namespaces 126 6.15 The Evolution of the Zend Engine 131 Chapter 7. I/O and Disk Access 132 7.1 HTTP Connections 134 7.2 Writing to the Browser 135 7.3 Output Buffering 136 7.4 Environment Variables 137 7.5 Getting Input from Forms 139 7.6 Passing Arrays in Forms 140 7.7 Cookies 141 7.8 File Uploads 143 7.9 Reading and Writing to Files 145 7.10 Sessions 147 7.11 The 'include' and 'require' Functions 149 7.12 Don't Trust User Input 150Part II: Functional Reference 152 Chapter 8. Browser I/O 153 8.1 Pregenerated Variables 157 8.2 Pregenerated Constants 160 8.3 Sending Text to the Browser 162 8.4 Output Buffering 165 8.5 Session Handling 171 8.6 HTTP Headers 173 Chapter 9. Operating System 174 9.1 Files 210 9.2 Compressed File Functions 215 9.3 Direct I/O 218 9.4 Debugging 238 9.5 POSIX 242 9.6 Shell Commands 246 9.7 Process Control 249 Chapter 10. Network I/O 250 10.1 General Network I/O 256 10.2 Sockets 268 10.3 FTP 277 10.4 Curl 287 10.5 SNMP 289 Chapter 11. Data 290 11.1 Data Types, Constants, and Variables 299 11.2 Arrays 326 11.3 Objects and Classes 330 11.4 User Defined Functions 334 Chapter 12. Encoding and Decoding 335 12.1 Strings 342 12.2 String Comparison 344 12.3 Encoding and Decoding 362 12.4 Compression 364 12.5 Encryption 370 12.6 Hashing 374 12.7 Spell Checking 378 12.8 Regular Expressions 384 12.9 Character Set Encoding 391 Chapter 13. Math 392 13.1 Common Math 400 13.2 Random Numbers 402 13.3 Arbitrary-Precision Numbers 404 Chapter 14. Time and Date 405 14.1 Time and Date 412 14.2 Alternative Calendars 416 Chapter 15. Configuration 417 15.1 Configuration Directives 435 15.2 Configuration 442 Chapter 16. Images and Graphics 443 16.1 Analyzing Images 446 16.2 Creating Images 481 Chapter 17. Database 482 17.1 DBM-Style Database Abstraction 486 17.2 DBX 489 17.3 LDAP 499 17.4 MySQL 509 17.5 ODBC 521 17.6 Oracle 533 17.7 Postgres 547 17.8 Sybase and Microsoft SQL Server 555 Chapter 18. Object Layers 556 18.1 COM 561 18.2 CORBA 562 18.3 Java 564 Chapter 19. Miscellaneous 565 19.1 Apache 567 19.2 IMAP 584 19.3 MnoGoSearch 590 19.4 OpenSSL 597 19.5 System V Messages 600 19.6 System V Semaphores 602 19.7 System V Shared Memory 605 Chapter 20. XML 607 20.1 DOM XML 617 20.2 Expat XML 627 20.3 WDDX 630Part III: Algorithms 631 Chapter 21. Sorting, Searching, and Random Numbers 632 21.1 Sorting 633 21.2 Built-In Sorting Functions 636 21.3 Sorting with a Comparison Function 639 21.4 Searching 641 21.5 Indexing 642 21.6 Random Numbers 644 21.7 Random Identifiers 645 21.8 Choosing Banner Ads 646 Chapter 22. Parsing and String Evaluation 647 22.1 Tokenizing 649 22.2 Regular Expressions 650 22.3 Defining Regular Expressions 652 22.4 Using Regular Expressions in PHP Scripts 657 Chapter 23. Database Integration 658 23.1 Building HTML Tables from SQL Queries 662 23.2 Tracking Visitors with Session Identifiers 670 23.3 Storing Content in a Database 675 23.4 Database Abstraction Layers 676 Chapter 24. Networks 677 24.1 HTTP Authentication 679 24.2 Controlling the Browser's Cache 681 24.3 Setting Document Type 682 24.4 Email with Attachments 685 24.5 HTML Email 687 24.6 Verifying an Email Address 691 Chapter 25. Generating Graphics 692 25.1 Dynamic Buttons 696 25.2 Generating Graphs on the Fly 697 25.3 Bar Graphs 700 25.4 Pie Charts 703 25.5 Stretching Single-Pixel Images 705Part IV: Software Engineering 706 Chapter 26. Integration with HTML 707 26.1 Sprinkling PHP within an HTML Document 713 26.2 Using PHP to Output All HTML 715 26.3 Separating HTML from PHP 717 26.4 Generating HTML with PHP 720 Chapter 27. Design 721 27.1 Writing Requirements Specifications 724 27.2 Writing Design Documents 725 27.3 Change Management 729 27.4 Modularization Using 'include' 731 27.5 FreeEnergy 733 27.6 Templates 737 27.7 Application Frameworks 738 27.8 PEAR 739 27.9 URLs Friendly to Search Engines 741 Chapter 28. Efficiency and Debugging 743 28.1 Optimization 744 28.2 Measuring Performance 747 28.3 Optimize the Slowest Parts 748 28.4 When to Store Content in a Database 749 28.5 Debugging Strategies 750 28.6 Simulating HTTP Connections 751 28.7 Output Buffering 752 28.8 Output Compression 753 28.9 Avoiding 'eval' 755 28.10 Don't Load Extensions Dynamically 756 28.11 Improving Performance of MySQL Queries 757 28.12 Optimizing Disk-Based Sessions 758 28.13 Don't Pass by Reference (or, Don't Trust Your Instincts) 760 28.14 Avoid Concatenation of Large Strings 761 28.15 Avoid Serving Large Files with PHP-Enabled Apache 762 28.16 Understanding Persistent Database Connections 763 28.17 Avoid Using 'exec', Backticks, and 'system' If Possible 764 28.18 Use 'php.ini-recommended' 765 28.19 Don't Use Regular Expressions Unless You Must 766 28.20 Optimizing Loops 767 28.21 IIS Configuration 768 Chapter 29. Design Patterns 769 29.1 Patterns Defined 771 29.2 Singleton 774 29.3 Factory 777 29.4 Observer 779 29.5 Strategy 782Appendix A. Escape Sequences 783Appendix B. ASCII Codes 787Appendix C. Operators 789Appendix D. PHP Tags 790Appendix E. PHP Compile-Time Configuration 794Appendix F. Internet Resources 795 F.1 Portals 796 F.2 Software 797Appendix G. PHP Style Guide 798 G.1 Comments 799 G.2 Function Declarations 800 G.3 Compound Statements 801 G.4 Naming 803 G.5 Expressions 804Index 805 Index SYMBOL 806 Index I [ Team LiB ] • Table of Contents • Index Core PHP Programming, Third Edition By Leon Atkinson Publisher: Prentice Hall PTR Pub Date: August 05, 2003 ISBN: 0-13-046346-9 Pages: 1104 Core PHP Programming, Third Edition is the authoritative guide to the new PHP 5 for experienced developers. Top PHP developer Leon Atkinson and PHP 5 contributor/Zend Engine 2 co-creator Zeev Suraski cover every facet of real-world PHP 5 development, from basic syntax to advanced object oriented development-even design patterns! It's all here: networking, data structures, regular expressions, math, configuration, graphics, MySQL/PostgreSQL support, XML, algorithms, debugging, optimization and 650 downloadable code examples, with a Foreword by PHP 5 contributor and Zend Engine 2 co-creator Andi Gutmans! [ Team LiB ] Prentice Hall PTR : Core PHP Programming, Third Edition 1 / 806 [ Team LiB ] • Table of Contents • Index Core PHP Programming, Third Edition By Leon Atkinson Publisher: Prentice Hall PTR Pub Date: August 05, 2003 ISBN: 0-13-046346-9 Pages: 1104 Copyright Praise for Core PHP Programming Prentice Hall PTR Core Series About Prentice Hall Professional Technical Reference Foreword Preface Acknowledgments Part I. Programming with PHP Chapter 1. An Introduction to PHP Section 1.1. The Origins of PHP Section 1.2. PHP Is Better Than Its Alternatives Section 1.3. Interfaces to External Systems Section 1.4. How PHP Works with the Web Server Section 1.5. Hardware and Software Requirements Section 1.6. What a PHP Script Looks Like Section 1.7. Saving Data for Later Section 1.8. Receiving User Input Section 1.9. Choosing Between Alternatives Section 1.10. Repeating Code Chapter 2. Variables, Operators, and Expressions Section 2.1. A Top-Down View Section 2.2. Data Types Section 2.3. Variables Section 2.4. Constants Section 2.5. Operators Section 2.6. Building Expressions Chapter 3. Control Statements Section 3.1. The if Statement Section 3.2. The ? Operator Section 3.3. The switch Statement Section 3.4. Loops Section 3.5. exit, die, and return Section 3.6. Exceptions Section 3.7. Declare Chapter 4. Functions Section 4.1. Declaring a Function Section 4.2. The return Statement Section 4.3. Scope Prentice Hall PTR : Core PHP Programming, Third Edition 2 / 806 Section 4.4. Static Variables Section 4.5. Arguments Section 4.6. Recursion Section 4.7. Dynamic Function Calls Chapter 5. Arrays Section 5.1. Single-Dimensional Arrays Section 5.2. Indexing Arrays Section 5.3. Initializing Arrays Section 5.4. Multidimensional Arrays Section 5.5. Casting Arrays Section 5.6. The + Operator Section 5.7. Referencing Arrays Inside Strings Chapter 6. Classes and Objects Section 6.1. Object-Oriented Programming Section 6.2. The PHP 5 Object Model Section 6.3. Defining a Class Section 6.4. Constructors and Destructors Section 6.5. Cloning Section 6.6. Accessing Properties and Methods Section 6.7. Static Class Members Section 6.8. Access Types Section 6.9. Binding Section 6.10. Abstract Methods and Abstract Classes Section 6.11. User-Level Overloading Section 6.12. Class Autoloading Section 6.13. Object Serialization Section 6.14. Namespaces Section 6.15. The Evolution of the Zend Engine Chapter 7. I/O and Disk Access Section 7.1. HTTP Connections Section 7.2. Writing to the Browser Section 7.3. Output Buffering Section 7.4. Environment Variables Section 7.5. Getting Input from Forms Section 7.6. Passing Arrays in Forms Section 7.7. Cookies Section 7.8. File Uploads Section 7.9. Reading and Writing to Files Section 7.10. Sessions Section 7.11. The include and require Functions Section 7.12. Don't Trust User Input Part II. Functional Reference Chapter 8. Browser I/O Section 8.1. Pregenerated Variables Section 8.2. Pregenerated Constants Section 8.3. Sending Text to the Browser Section 8.4. Output Buffering Section 8.5. Session Handling Section 8.6. HTTP Headers Chapter 9. Operating System Section 9.1. Files Section 9.2. Compressed File Functions Section 9.3. Direct I/O Section 9.4. Debugging Section 9.5. POSIX Section 9.6. Shell Commands Section 9.7. Process Control Chapter 10. Network I/O Prentice Hall PTR : Core PHP Programming, Third Edition 3 / 806 Section 10.1. General Network I/O Section 10.2. Sockets Section 10.3. FTP Section 10.4. Curl Section 10.5. SNMP Chapter 11. Data Section 11.1. Data Types, Constants, and Variables Section 11.2. Arrays Section 11.3. Objects and Classes Section 11.4. User Defined Functions Chapter 12. Encoding and Decoding Section 12.1. Strings Section 12.2. String Comparison Section 12.3. Encoding and Decoding Section 12.4. Compression Section 12.5. Encryption Section 12.6. Hashing Section 12.7. Spell Checking Section 12.8. Regular Expressions Section 12.9. Character Set Encoding Chapter 13. Math Section 13.1. Common Math Section 13.2. Random Numbers Section 13.3. Arbitrary-Precision Numbers Chapter 14. Time and Date Section 14.1. Time and Date Section 14.2. Alternative Calendars Chapter 15. Configuration Section 15.1. Configuration Directives Section 15.2. Configuration Chapter 16. Images and Graphics Section 16.1. Analyzing Images Section 16.2. Creating Images Chapter 17. Database Section 17.1. DBM-Style Database Abstraction Section 17.2. DBX Section 17.3. LDAP Section 17.4. MySQL Section 17.5. ODBC Section 17.6. Oracle Section 17.7. Postgres Section 17.8. Sybase and Microsoft SQL Server Chapter 18. Object Layers Section 18.1. COM Section 18.2. CORBA Section 18.3. Java Chapter 19. Miscellaneous Section 19.1. Apache Section 19.2. IMAP Section 19.3. MnoGoSearch Section 19.4. OpenSSL Section 19.5. System V Messages Section 19.6. System V Semaphores Section 19.7. System V Shared Memory Chapter 20. XML Section 20.1. DOM XML Section 20.2. Expat XML Section 20.3. WDDX Prentice Hall PTR : Core PHP Programming, Third Edition 4 / 806 Section 20.3. WDDX Part III. Algorithms Chapter 21. Sorting, Searching, and Random Numbers Section 21.1. Sorting Section 21.2. Built-In Sorting Functions Section 21.3. Sorting with a Comparison Function Section 21.4. Searching Section 21.5. Indexing Section 21.6. Random Numbers Section 21.7. Random Identifiers Section 21.8. Choosing Banner Ads Chapter 22. Parsing and String Evaluation Section 22.1. Tokenizing Section 22.2. Regular Expressions Section 22.3. Defining Regular Expressions Section 22.4. Using Regular Expressions in PHP Scripts Chapter 23. Database Integration Section 23.1. Building HTML Tables from SQL Queries Section 23.2. Tracking Visitors with Session Identifiers Section 23.3. Storing Content in a Database Section 23.4. Database Abstraction Layers Chapter 24. Networks Section 24.1. HTTP Authentication Section 24.2. Controlling the Browser's Cache Section 24.3. Setting Document Type Section 24.4. Email with Attachments Section 24.5. HTML Email Section 24.6. Verifying an Email Address Chapter 25. Generating Graphics Section 25.1. Dynamic Buttons Section 25.2. Generating Graphs on the Fly Section 25.3. Bar Graphs Section 25.4. Pie Charts Section 25.5. Stretching Single-Pixel Images Part IV. Software Engineering Chapter 26. Integration with HTML Section 26.1. Sprinkling PHP within an HTML Document Section 26.2. Using PHP to Output All HTML Section 26.3. Separating HTML from PHP Section 26.4. Generating HTML with PHP Chapter 27. Design Section 27.1. Writing Requirements Specifications Section 27.2. Writing Design Documents Section 27.3. Change Management Section 27.4. Modularization Using include Section 27.5. FreeEnergy Section 27.6. Templates Section 27.7. Application Frameworks Section 27.8. PEAR Section 27.9. URLs Friendly to Search Engines Chapter 28. Efficiency and Debugging Section 28.1. Optimization Section 28.2. Measuring Performance Section 28.3. Optimize the Slowest Parts Section 28.4. When to Store Content in a Database Section 28.5. Debugging Strategies Section 28.6. Simulating HTTP Connections Section 28.7. Output Buffering Prentice Hall PTR : Core PHP Programming, Third Edition 5 / 806 [...]... Prentice Hall PTR : Core PHP Programming, Third Edition [ Team LiB ] Prentice Hall PTR Core Series Core MySQL, Atkinson Core PHP Programming, 3/e, Atkinson Core Python Programming, Chun Core Java Media Framework, Decarmo Core Jini, 2/e,[*] Edwards [*] Sun Microsystems Press titles Core Servlets and JavaServer Pages ,[*] Hall Core Web Programming, 2/e,[*] Hall/Brown Core ColdFusion 5, Hewitt Core Java 2, Vol... Horstmann/Cornell Core Java 2, Vol II–Advanced Features ,[*] Horstmann/Cornell Core JSP, Hougland & Tavistock Core Perl, Lerner Core CSS, Schengili-Roberts Core C++: A Software Engineering Approach , Shtern Core Java Web Server, Taylor & Kimmet Core JFC, 2/e, Topley Core Swing: Advanced Programming , Topley Core Web3D, Walsh & Bourges-Sévenier [ Team LiB ] 12 / 806 Prentice Hall PTR : Core PHP Programming, ... North Asia Ltd 7 / 806 Prentice Hall PTR : Core PHP Programming, Third Edition Pearson Education Canada, Ltd Pearson Educación de Mexico, S.A de C.V Pearson Education—Japan Pearson Education Malaysia, Pte Ltd [ Team LiB ] 8 / 806 Prentice Hall PTR : Core PHP Programming, Third Edition [ Team LiB ] Praise for Core PHP Programming "Bought your book Core PHP Programming at a Barnes and Noble here in Tucson... can find an up-to-date list of credits on the PHP site [ Team LiB ] 21 / 806 Prentice Hall PTR : Core PHP Programming, Third Edition [ Team LiB ] 1.2 PHP Is Better Than Its Alternatives In previous years, skeptics may have asked, Why should I learn PHP? Today, PHP' s popularity is enough to generate interest in learning it PHP is a standard feature offered by most Web... recognizes PHP scripts Somewhere in Apache's configuration file, httpd.conf, you need an AddType directive that matches scripts ending in php with application/x-httpd -php You also need to load the PHP module If the lines in Listing 1.4 do not appear in httpd.conf, add them Listing 1.4 Activating PHP for Apache LoadModule php5 _module libexec/libphp5.so AddType application/x-httpd -php php AddModule mod _php5 .c... encouraged me to continue with the PHP project throughout the years And finally, I would like to thank my girlfriend for putting up with the weekends I had to spend writing Zeev Suraski August 2003 [ Team LiB ] 17 / 806 Prentice Hall PTR : Core PHP Programming, Third Edition [ Team LiB ] Part I: Programming with PHP The first part of this book is a thorough discussion of PHP as a programming language You will... Chapter 7 I/O and Disk Access [ Team LiB ] 18 / 806 Prentice Hall PTR : Core PHP Programming, Third Edition [ Team LiB ] Chapter 1 An Introduction to PHP Topics in This Chapter The Origins of PHP PHP Is Better Than Its Alternatives Interfaces to External Systems How PHP Works with the Web Server Hardware and Software Requirements What a PHP Script Looks Like Saving Data for Later Receiving User Input Choosing... purchased your book, Core PHP Programming , 2nd Edition, and I think it is wonderful!!! Very easy to read —and retain—so far I just want to thank you ahead of time because all the other PHP books I've purchased and read got me nowhere!" —Neal Levine http://www.ilaonline.com "I recently purchased your Core PHP Programming book, and I just wanted to let you know that it is one of the best programming books... applied to PHP PHP takes inspiration from both Perl and C Experienced Perl and C programmers learn PHP very quickly Likewise, programmers who learn PHP as a first language may apply their knowledge toward not only Perl and C, but other C-like languages such as Java [ Team LiB ] 22 / 806 Prentice Hall PTR : Core PHP Programming, Third Edition [ Team LiB ] 1.3 Interfaces to External Systems Originally, PHP. .. configuration options, PHP uses a file called php. ini This file should reside in /usr/local/lib, so copy it from the PHP source directory (Listing 1.3): Listing 1.3 Copying php. ini cp php. ini-dist /usr/local/lib /php. ini You may not need to edit this file It controls certain aspects of PHP, including support for historic behavior Chapter 15 discusses configuration directives you may use in php. ini Many of . Prentice Hall PTR : Core PHP Programming, Third Edition 8 / 806 [ Team LiB ] Praise for Core PHP Programming "Bought your book Core PHP Programming at. : Core PHP Programming, Third Edition 11 / 806 [ Team LiB ] Prentice Hall PTR Core Series Core MySQL, Atkinson Core PHP Programming, 3/e, Atkinson Core

Ngày đăng: 24/01/2014, 14:22

Từ khóa liên quan

Mục lục

  • Main Page

  • Table of content

  • Copyright

  • Praise for 'Core PHP Programming'

  • Prentice Hall PTR Core Series

  • About Prentice Hall Professional Technical Reference

  • Foreword

  • Preface

  • Acknowledgments

  • Part I: Programming with PHP

    • Chapter 1. An Introduction to PHP

      • 1.1 The Origins of PHP

      • 1.2 PHP Is Better Than Its Alternatives

      • 1.3 Interfaces to External Systems

      • 1.4 How PHP Works with the Web Server

      • 1.5 Hardware and Software Requirements

      • 1.6 What a PHP Script Looks Like

      • 1.7 Saving Data for Later

      • 1.8 Receiving User Input

      • 1.9 Choosing Between Alternatives

      • 1.10 Repeating Code

      • Chapter 2. Variables, Operators, and Expressions

        • 2.1 A Top-Down View

Tài liệu cùng người dùng

Tài liệu liên quan