programming php

540 302 0
programming php

Đ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

Table of Contents 1Main Page 2Table of content 6Copyright 7Preface 8 Audience for This Book 9 Structure of This Book 10 Conventions Used in This Book 11 Comments and Questions 12 Acknowledgments 13Chapter 1. Introduction to PHP 14 1.1 What Does PHP Do? 15 1.2 A Brief History of PHP 19 1.3 Installing PHP 21 1.4 A Walk Through PHP 27Chapter 2. Language Basics 28 2.1 Lexical Structure 34 2.2 Data Types 40 2.3 Variables 44 2.4 Expressions and Operators 55 2.5 Flow-Control Statements 63 2.6 Including Code 65 2.7 Embedding PHP in Web Pages 68Chapter 3. Functions 69 3.1 Calling a Function 70 3.2 Defining a Function 72 3.3 Variable Scope 74 3.4 Function Parameters 77 3.5 Return Values 78 3.6 Variable Functions 79 3.7 Anonymous Functions 80Chapter 4. Strings 81 4.1 Quoting String Constants 84 4.2 Printing Strings 88 4.3 Accessing Individual Characters 89 4.4 Cleaning Strings 91 4.5 Encoding and Escaping 96 4.6 Comparing Strings 99 4.7 Manipulating and Searching Strings 105 4.8 Regular Expressions 109 4.9 POSIX-Style Regular Expressions 113 4.10 Perl-Compatible Regular Expressions 123Chapter 5. Arrays 124 5.1 Indexed Versus Associative Arrays 125 5.2 Identifying Elements of an Array 126 5.3 Storing Data in Arrays 129 5.4 Multidimensional Arrays 130 5.5 Extracting Multiple Values 134 5.6 Converting Between Arrays and Variables 135 5.7 Traversing Arrays 140 5.8 Sorting 144 5.9 Acting on Entire Arrays 146 5.10 Using Arrays 148Chapter 6. Objects 149 6.1 Terminology 150 6.2 Creating an Object 151 6.3 Accessing Properties and Methods 152 6.4 Declaring a Class 156 6.5 Introspection 162 6.6 Serialization 165Chapter 7. Web Techniques 166 7.1 HTTP Basics 167 7.2 Variables 168 7.3 Server Information 170 7.4 Processing Forms 180 7.5 Setting Response Headers 183 7.6 Maintaining State 191 7.7 SSL 192Chapter 8. Databases 193 8.1 Using PHP to Access a Database 195 8.2 Relational Databases and SQL 196 8.3 PEAR DB Basics 202 8.4 Advanced Database Techniques 207 8.5 Sample Application 215Chapter 9. Graphics 216 9.1 Embedding an Image in a Page 218 9.2 The GD Extension 219 9.3 Basic Graphics Concepts 220 9.4 Creating and Drawing Images 224 9.5 Images with Text 227 9.6 Dynamically Generated Buttons 230 9.7 Scaling Images 232 9.8 Color Handling 236Chapter 10. PDF 237 10.1 PDF Extensions 238 10.2 Documents and Pages 241 10.3 Text 249 10.4 Images and Graphics 257 10.5 Navigation 260 10.6 Other PDF Features 262Chapter 11. XML 263 11.1 Lightning Guide to XML 265 11.2 Generating XML 267 11.3 Parsing XML 277 11.4 Transforming XML with XSLT 280 11.5 Web Services 284Chapter 12. Security 285 12.1 Global Variables and Form Data 287 12.2 Filenames 289 12.3 File Uploads 291 12.4 File Permissions 294 12.5 Concealing PHP Libraries 295 12.6 PHP Code 297 12.7 Shell Commands 298 12.8 Security Redux 299Chapter 13. Application Techniques 300 13.1 Code Libraries 301 13.2 Templating Systems 304 13.3 Handling Output 306 13.4 Error Handling 310 13.5 Performance Tuning 316Chapter 14. Extending PHP 317 14.1 Architectural Overview 318 14.2 What You'll Need 319 14.3 Building Your First Extensions 326 14.4 The config.m4 File 328 14.5 Memory Management 330 14.6 The pval/zval Data Type 333 14.7 Parameter Handling 336 14.8 Returning Values 340 14.9 References 342 14.10 Global Variables 344 14.11 Creating Variables 346 14.12 Extension INI Entries 348 14.13 Resources 350 14.14 Where to Go from Here 351Chapter 15. PHP on Windows 352 15.1 Installing and Configuring PHP on Windows 355 15.2 Writing Portable Code for Windows and Unix 359 15.3 Interfacing with COM 366 15.4 Interacting with ODBC Data Sources 371Appendix A. Function Reference 372 A.1 PHP Functions by Category 375 A.2a Alphabetical Listing of PHP Functions (a-e) 392 A.2b Alphabetical Listing of PHP Functions (f-i) 409 A.2c Alphabetical Listing of PHP Functions (j-q) 423 A.3d Alphabetical Listing of PHP Functions (r-z) 441Appendix B. Extension Overview 442 B.1 Optional Extensions Listing 454 Colophone 455Index 456 Index SYMBOL 460 Index A 464 Index B 466 Index C 472 Index D 476 Index E 481 Index F 486 Index G 489 Index H 491 Index I 495 Index J 496 Index K 497 Index L 499 Index M 502 Index N 504 Index O 507 Index P 514 Index Q 515 Index R 518 Index S 525 Index T 527 Index U 529 Index V 531 Index W 533 Index X 535 Index Y 536 Index Z I l@ve RuBoard • Table of Contents • Index • Reviews • Examples • Reader Reviews • Errata Programming PHP By Rasmus Lerdorf, Kevin Tatroe Publisher: O'Reilly Pub Date: March 2002 ISBN : 1-56592-610-2 Pages : 524 Programming PHP is a comprehensive guide to PHP, a simple yet powerful language for creating dynamic web content. Filled with the unique knowledge of the creator of PHP, Rasmus Lerdorf, this book is a detailed reference to the language and its applications, including such topics as form processing, sessions, databases, XML, and graphics. Covers PHP 4, the latest version of the language. I l@ve RuBoard O'Reilly: Programming PHP Main Page 1 / 536 I l@ve RuBoard • Table of Contents • Index • Reviews • Examples • Reader Reviews • Errata Programming PHP By Rasmus Lerdorf, Kevin Tatroe Publisher: O'Reilly Pub Date: March 2002 ISBN : 1-56592-610-2 Pages : 524 Copyright Preface Audience for This Book Structure of This Book Conventions Used in This Book Comments and Questions Acknowledgments Chapter 1. Introduction to PHP Section 1.1. What Does PHP Do? Section 1.2. A Brief History of PHP Section 1.3. Installing PHP Section 1.4. A Walk Through PHP Chapter 2. Language Basics Section 2.1. Lexical Structure Section 2.2. Data Types Section 2.3. Variables Section 2.4. Expressions and Operators Section 2.5. Flow-Control Statements Section 2.6. Including Code Section 2.7. Embedding PHP in Web Pages Chapter 3. Functions Section 3.1. Calling a Function Section 3.2. Defining a Function Section 3.3. Variable Scope Section 3.4. Function Parameters Section 3.5. Return Values Section 3.6. Variable Functions Section 3.7. Anonymous Functions O'Reilly: Programming PHP Table of content 2 / 536 Chapter 4. Strings Section 4.1. Quoting String Constants Section 4.2. Printing Strings Section 4.3. Accessing Individual Characters Section 4.4. Cleaning Strings Section 4.5. Encoding and Escaping Section 4.6. Comparing Strings Section 4.7. Manipulating and Searching Strings Section 4.8. Regular Expressions Section 4.9. POSIX-Style Regular Expressions Section 4.10. Perl-Compatible Regular Expressions Chapter 5. Arrays Section 5.1. Indexed Versus Associative Arrays Section 5.2. Identifying Elements of an Array Section 5.3. Storing Data in Arrays Section 5.4. Multidimensional Arrays Section 5.5. Extracting Multiple Values Section 5.6. Converting Between Arrays and Variables Section 5.7. Traversing Arrays Section 5.8. Sorting Section 5.9. Acting on Entire Arrays Section 5.10. Using Arrays Chapter 6. Objects Section 6.1. Terminology Section 6.2. Creating an Object Section 6.3. Accessing Properties and Methods Section 6.4. Declaring a Class Section 6.5. Introspection Section 6.6. Serialization Chapter 7. Web Techniques Section 7.1. HTTP Basics Section 7.2. Variables Section 7.3. Server Information Section 7.4. Processing Forms Section 7.5. Setting Response Headers Section 7.6. Maintaining State Section 7.7. SSL Chapter 8. Databases Section 8.1. Using PHP to Access a Database Section 8.2. Relational Databases and SQL Section 8.3. PEAR DB Basics Section 8.4. Advanced Database Techniques Section 8.5. Sample Application Chapter 9. Graphics Section 9.1. Embedding an Image in a Page Section 9.2. The GD Extension Section 9.3. Basic Graphics Concepts Section 9.4. Creating and Drawing Images Section 9.5. Images with Text Section 9.6. Dynamically Generated Buttons O'Reilly: Programming PHP Table of content 3 / 536 Section 9.7. Scaling Images Section 9.8. Color Handling Chapter 10. PDF Section 10.1. PDF Extensions Section 10.2. Documents and Pages Section 10.3. Text Section 10.4. Images and Graphics Section 10.5. Navigation Section 10.6. Other PDF Features Chapter 11. XML Section 11.1. Lightning Guide to XML Section 11.2. Generating XML Section 11.3. Parsing XML Section 11.4. Transforming XML with XSLT Section 11.5. Web Services Chapter 12. Security Section 12.1. Global Variables and Form Data Section 12.2. Filenames Section 12.3. File Uploads Section 12.4. File Permissions Section 12.5. Concealing PHP Libraries Section 12.6. PHP Code Section 12.7. Shell Commands Section 12.8. Security Redux Chapter 13. Application Techniques Section 13.1. Code Libraries Section 13.2. Templating Systems Section 13.3. Handling Output Section 13.4. Error Handling Section 13.5. Performance Tuning Chapter 14. Extending PHP Section 14.1. Architectural Overview Section 14.2. What You'll Need Section 14.3. Building Your First Extensions Section 14.4. The config.m4 File Section 14.5. Memory Management Section 14.6. The pval/zval Data Type Section 14.7. Parameter Handling Section 14.8. Returning Values Section 14.9. References Section 14.10. Global Variables Section 14.11. Creating Variables Section 14.12. Extension INI Entries Section 14.13. Resources Section 14.14. Where to Go from Here Chapter 15. PHP on Windows Section 15.1. Installing and Configuring PHP on Windows Section 15.2. Writing Portable Code for Windows and Unix Section 15.3. Interfacing with COM O'Reilly: Programming PHP Table of content 4 / 536 Section 15.4. Interacting with ODBC Data Sources Appendix A. Function Reference Section A.1. PHP Functions by Category Section A.2a. Alphabetical Listing of PHP Functions (a-e) Section A.2b. Alphabetical Listing of PHP Functions (f-i) Section A.2c. Alphabetical Listing of PHP Functions (j-q) Section A.3d. Alphabetical Listing of PHP Functions (r-z) Appendix B. Extension Overview Section B.1. Optional Extensions Listing Colophon Index I l@ve RuBoard O'Reilly: Programming PHP Table of content 5 / 536 I l@ve RuBoard Copyright Copyright © 2002 O'Reilly & Associates, Inc. All rights reserved. Printed in the United States of America. Published by O'Reilly & Associates, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O'Reilly & Associates books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safari.oreilly.com). For more information contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com. Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly & Associates, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. The association between the image of a cuckoo and PHP is a trademark of O'Reilly & Associates, Inc. While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. I l@ve RuBoard O'Reilly: Programming PHP Copyright 6 / 536 [...]... graphics I l@ve RuBoard 13 / 536 O'Reilly: Programming PHP 1.1 What Does PHP Do? I l@ve RuBoard 1.1 What Does PHP Do? PHP can be used in three primary ways: Server-side scripting PHP was originally designed to create dynamic web content, and it is still best suited for that task To generate HTML, you need the PHP parser and a web server to send the documents Lately, PHP has also become popular for generating... simple Finally, PHP provides a library of PHP code to perform common tasks, such as database abstraction, error handling, and so on, with the PHP Extension and Application Repository (PEAR) PEAR is a framework and distribution system for reusable PHP components You can find out more about it at http://pear .php. net I l@ve RuBoard 14 / 536 O'Reilly: Programming PHP 1.2 A Brief History of PHP I l@ve RuBoard... Net, Inc "Our use of PHP has cut our development time in half, and more than doubled our client satisfaction PHP has enabled us to provide database-driven dynamic solutions which perform at phenomenal speeds." PHP 3.0 is available for free download in source form and binaries for several platforms at http://www .php. net/ 17 / 536 O'Reilly: Programming PHP 1.2 A Brief History of PHP The PHP Development Team... using the PHP module In November 2001, when Netcraft found 36,458,394 different domains, 7,095,691 ( just under 20%) of them were found to have PHP enabled The domain figures represent the number of web sites using PHP, whereas IP addresses represent the number of physical servers running PHP Figure 1-2 The growth of PHP domains I l@ve RuBoard 18 / 536 O'Reilly: Programming PHP 1.3 Installing PHP I l@ve... newly built PHP module, and compile and install it: # # # # cd /apache_1.3.22 /configure prefix=/usr/local/apache activate-module=src/modules /php4 /libphp4.a make make install You now have Apache installed in /usr/local/apache, with PHP enabled You also have PHP' s extensions installed (probably in /usr/local/lib /php) You still need to configure the web server to process php pages with the PHP interpreter,... 536 O'Reilly: Programming PHP 1.4 A Walk Through PHP I l@ve RuBoard 1.4 A Walk Through PHP PHP pages are HTML pages with PHP commands embedded in them This is in contrast to many other dynamic web-page solutions, which are scripts that generate HTML The web server processes the PHP commands and sends their output (and any HTML from the file) to the browser Example 1-1 shows a complete PHP page Example... phpinfo( ) page Example 1-2 Using phpinfo( ) < ?php phpinfo( ); ?> Figure 1-4 shows the first part of the output of Example 1-2 Figure 1-4 Partial output of phpinfo( ) 21 / 536 O'Reilly: Programming PHP 1.4 A Walk Through PHP 1.4.2 Forms Example 1-3 creates and processes a form When the user submits the form, the information typed into the name field is sent back to this page The PHP code tests for a name field... Introduction to PHP I l@ve RuBoard Chapter 1 Introduction to PHP PHP is a simple yet powerful language designed for creating HTML content This chapter covers essential background on the PHP language It describes the nature and history of PHP; which platforms it runs on; and how to download, install, and configure it This chapter ends by showing you PHP in action, with a quick walkthrough of several PHP programs... between < ?php and ?> tags There are other ways to tag your PHP code�see Chapter 2 for a full description 1.4.1 Configuration Page The PHP function phpinfo( ) creates an HTML page full of information on how PHP was installed You can use it to see whether you have particular extensions installed, or whether the php. ini file has been customized Example 1-2 is a complete page that displays the phpinfo(... apache-devel packages PHP' s configuration goes in a file called php. ini The settings in this file control the behavior of PHP features, such as session handling and form processing Later chapters will refer to php. ini options, but in general the code in this book does not require a customized configuration See http://www .php. net/manual/en/configuration .php for more information on php. ini configuration . RuBoard O'Reilly: Programming PHP 1.1 What Does PHP Do? 14 / 536 I l@ve RuBoard 1.2 A Brief History of PHP Rasmus Lerdorf first conceived of PHP in 1994, but the PHP that people use today. Reviews • Errata Programming PHP By Rasmus Lerdorf, Kevin Tatroe Publisher: O'Reilly Pub Date: March 2002 ISBN : 1-56592-610-2 Pages : 524 Programming PHP is a comprehensive guide to PHP, a simple. Acknowledgments Chapter 1. Introduction to PHP Section 1.1. What Does PHP Do? Section 1.2. A Brief History of PHP Section 1.3. Installing PHP Section 1.4. A Walk Through PHP Chapter 2. Language Basics

Ngày đăng: 05/04/2014, 19:52

Mục lục

  • Preface

    • Audience for This Book

    • Structure of This Book

    • Conventions Used in This Book

    • Chapter 1. Introduction to PHP

      • 1.1 What Does PHP Do?

      • 1.2 A Brief History of PHP

      • 1.4 A Walk Through PHP

      • 2.7 Embedding PHP in Web Pages

      • 4.7 Manipulating and Searching Strings

      • Chapter 5. Arrays

        • 5.1 Indexed Versus Associative Arrays

        • 5.2 Identifying Elements of an Array

        • 5.3 Storing Data in Arrays

        • 5.6 Converting Between Arrays and Variables

        • 5.9 Acting on Entire Arrays

        • 6.3 Accessing Properties and Methods

        • Chapter 8. Databases

          • 8.1 Using PHP to Access a Database

          • 8.2 Relational Databases and SQL

          • Chapter 9. Graphics

            • 9.1 Embedding an Image in a Page

            • 9.4 Creating and Drawing Images

            • Chapter 11. XML

              • 11.1 Lightning Guide to XML

              • 11.4 Transforming XML with XSLT

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

  • Đang cập nhật ...

Tài liệu liên quan