Home > Store

Core PHP Programming: Using PHP to Build Dynamic Web Sites, 2nd Edition

Register your product to gain access to bonus material or receive a coupon.

Core PHP Programming: Using PHP to Build Dynamic Web Sites, 2nd Edition

  • By
  • Published Aug 3, 2000 by Pearson. Part of the Core Series series.

Book

  • Sorry, this book is no longer in print.
Not for Sale

About

Features

  • NEW - Detailed reference and examples—For every key PHP function plus many extensions.
    • Helps students understand syntax.

  • NEW - Newest version of PHP covered—4.0.
    • Provides students with the most up-to-date programming features.

  • NEW - CD-ROM—Includes all the source code from the book along with PHP 4.0 for Windows, Linux, and Solaris platforms.
    • Student does not need to key-in sample programs.

  • Four main sections—An introduction to programming, a reference for all the functions in PHP, a survey of common programming problems, and a guide for applying this knowledge to Website development.
    • Provides the student with a tutorial and reference.

Description

  • Copyright 2001
  • Edition: 2nd
  • Book
  • ISBN-10: 0-13-089398-6
  • ISBN-13: 978-0-13-089398-7

  • Master PHP 4 — the open source Web scripting breakthrough
  • Contains expert coverage of syntax, functions, design, and debugging
  • Leverage the amazing performance of the new Zend engine!
  • 650+ real-world code examples
  • CD-ROM includes source code, plus everything you'll need to run PHP 4 implementations on Windows and UNIX

Foreword by Andi Gutmans

Praise for the first edition:

Core PHP Programming has proved itself an invaluable technical reference. I highly recommend it for beginners as well, since the official PHP manual often assumes too much knowledge on behalf of the user. Leon's strength is that he does not try to sound more technical than needed, simply for the sake of impressing other programmers. In short, a must-have for any PHP user, beginning or advanced!
—Zack Beatty, Enterprise Web Engineer

The experienced developer's guide to PHP!

Master PHP 4, the open source, high-performance, cross-platform solution for server-side scripting!

Core PHP Programming, Second Edition is the #1 practical guide to PHP 4 for Web developers. With the guidance of top PHP developer Leon Atkinson, you'll learn everything you'll need to build robust, fast Web applications — and deploy them on leading Web servers, from Apache to Microsoft Internet Information Server.

Atkinson covers PHP syntax, the key building blocks of PHP scripts, and every PHP function, including I/O, data, and math functions, time, date, configuration, database, graphics, and network functions. He presents PHP at work in sample code that demonstrates sorting, searching, parsing, string evaluation, and more. You'll even find detailed, real-world insights into PHP 4 program design and debugging!

Core PHP Programming delivers

  • Thorough, easy-to-understand coverage of PHP syntax and functions
  • Step-by-step guidance for PHP database integration
  • Design and optimization techniques for maximum performance and extensibility
  • Practical debugging solutions

CD-ROM includes PHP 4 source code and Windows binaries plus all the code examples from the book!

Sample Content

Downloadable Sample Chapter

Click here for a sample chapter for this book: 0130893986.pdf

Table of Contents

I. PROGRAMMING WITH PHP.

1. An Introduction to PHP.

The Origins of PHP. What Makes PHP Better than Its Alternatives. Interfaces to External Systems. How PHP Works with the Web Server. Hardware and Software Requirements. Installation on Apache for UNIX. Installation on IIS for Windows NT. Editing Scripts. Algorithms. What a PHP Script Looks Like. Saving Data for Later. Receiving User Input. Choosing between Alternatives. Repeating Code. Conclusion.

2. Variables, Operators, and Expressions.

Identifiers. Data Types. Variable Creation and Scope. Assigning Values to Variables. Retrieving Values. Freeing Memory. Constants. Operators. Logical and Relational Operators. Bitwise Operators. Miscellaneous Operators. Assignment Operators. Expressions.

3. Control Statements.

True and False. The if Statement. The ? Operator. The switch Statement. Loops. The while Statement. The break Statement. The continue Statement. The do while Statement. The for Statement. The foreach Statement. exit, die, and return. Evaluation of Boolean Expressions.

4. Functions.

Declaring a Function. The return Statement. Scope and the global Statement. Arguments. Recursion. Dynamic Function Calls.

5. Arrays.

Single-Dimensional Arrays. Indexing Arrays. Initializing Arrays. Multidimensional Arrays. Casting Arrays. Referencing Arrays Inside Strings.

6. Classes and Objects.

Defining a Class. Creating an Object. Accessing Properties and Methods.

7. I/O and Disk Access.

HTTP Connections. Writing to the Browser. Output Buffering. Environment Variables. Getting Input from Forms. Cookies. File Uploads. PUT Method Requests. Reading and Writing to Files. Sessions. The include and require Functions.

II. FUNCTIONAL REFERENCE.

8. I/O Functions.

Sending Text to the Browser. Output Buffering. Files. Compressed File Functions. POSIX. Debugging. Session Handling. Shell Commands. HTTP Headers. Network I/O. FTP.

9. Data Functions.

Data Types, Constants, and Variables. Arrays. Hashing. Strings. Encoding and Decoding. Encryption. Regular Expressions. Perl-Compatible Regular Expressions.

10. Mathematical Functions.

Common Math. Random Numbers. Arbitrary-Precision Numbers.

11. Time, Date, and Configuration Functions.

Time and Date. Alternative Calendars. Configuration.

12. Image Functions.

Analyzing Images. Creating JPEG, PNG, and WBMP Images.

13. Database Functions.

dBase. DBM-style Database Abstraction. filePro. Informix. InterBase. mSQL. MySQL. ODBC. Oracle. Postgres. Sybase.

14. Miscellaneous Functions.

Apache. Aspell. COM. Gettext. IMAP. Java. LDAP. Semaphores. Shared Memory. SNMP. WDDX. XML.

III. ALGORITHMS.

15. Sorting, Searching, and Random Numbers.

Sorting. Bubble Sort. Quicksort. Built-In Sorting Functions. Sorting with a Comparison Function. Searching. Indexing. Random Numbers. Random Identifiers. Choosing Banner Ads.

16. Parsing and String Evaluation.

Tokenizing. Regular Expressions. Defining Regular Expressions. Using Regular Expressions in PHP Scripts.

17. Database Integration.

Building HTML Tables from SQL Queries. Tracking Visitors with Session Identifiers. Storing Content in a Database. Database Abstraction Layers.

18. Network.

HTTP Authentication. Controlling Browser Cache. Setting Document Type. Email with Attachments. Verifying an Email Address.

19. Generating Graphics.

Dynamic Buttons. Generating Graphs on the Fly. Bar Graphs. Pie Charts. Stretching Single-Pixel Images.

IV. SOFTWARE ENGINEERING.

20. Integration with HTML.

Sprinkling PHP within an HTML Document. Using PHP to Output All HTML. Separating HTML from PHP. Creating <W9S> Fields. Passing Arrays in Forms.

21. Design.

Writing Requirements Specifications. Writing Design Documents. Using CVS. Modularization Using include. FreeEnergy. FastTemplate. Midgard. Ariadne. Preserving State and Providing Security. Cloaking. URLs Friendly to Search Engines. Running a Script Regularly.

22. Efficiency and Debugging.

Measuring Performance. Fetching Database Query Results. When to Store Content in a Database. In-Line Debugging. Remote Debugging. Simulating HTTP Connections.

Appendix A.
Appendix B.
Appendix C.
Appendix D.
Appendix E.
Appendix F.
Appendix G.
Index.

Preface

Preface

My first inkling that I might like to write a book about PHP was born out of the frustration I felt with the original PHP manual. It was a single, large HTML file with all the functions in alphabetical order. It was also on a Web server thousands of miles away from me in Canada, so it was slow to show up in my browser, even across a T1 connection. It wasn't long before it was saved on my desktop. After struggling for several months, it started to dawn on me that I could probably organize the information into a more usable format. Around that time the next version of PHP began to take shape, and with it a new manual was developed. It was organized around PHP's source code but was less complete than the old PHP manual. I contributed descriptions for some of the missing functions, but I still had the idea to write my own manual. In the spring of 1998 Prentice Hall PTR gave me the opportunity to do so. It is an honor for my book to be among Prentice Hall classics such as The C Programming Language by Brian Kernighan and Dennis Ritchie.

This book assumes a certain familiarity with the Internet, the Web, and HTML programming, but it starts with the most basic ideas of programming. It will introduce you to concepts common to all programming languages and how they work in PHP. You can expect this book to teach you how to create rich, dynamic Web sites. You can also expect it to remain on your desk as a reference for how PHP works, or even as a recipe book for solving common design problems.

This book is not for dummies, nor is it for complete idiots. That you are considering PHP is a great indication of your intelligence, and I'd hate to insult it. Some of the ideas in this book are hard to understand. If you don't quite get them the first time, I encourage you to reread and experiment with the examples.

If you are uncomfortable writing HTML files, you may wish to develop this skill first. Marty Hall's Core Web Programming provides an excellent introduction. Beyond HTML, numerous other topics I touch on fall out of scope. Whenever I can, I suggest books and Web sites that provide more information. There are even some aspects of PHP that range too far from the focus on writing PHP scripts. An example is writing extensions for PHP in C. This involves a healthy knowledge of C programming that I cannot provide here. Related to this is compiling and installing PHP. I attempt to describe the process of installing PHP, which can involve compiling the source code, but I can't attempt to pursue all the different combinations of operating system, Web servers, and extensions. If you are comfortable running make files, you will find the information that comes with the PHP source code more than adequate.

Along with the explanation text I've provided real-world examples. Nothing is more frustrating than trying to adapt some contrived academic problem to the Web site you must have working by the end of the week. Some of the examples are based on code from live Web sites I have worked on since discovering PHP in 1997. Others are distilled from the continual discussion being conducted on the PHP mailing lists.

This book is organized into four main sections: an introduction to programming; a reference for all the functions in PHP; a survey of common programming problems; and finally a guide for applying this knowledge to Web site development. The first section deals with the issues involved with any programming language: what a PHP script looks like; how to control execution; how to deal with data. The second section organizes the functions by what they do and gives examples of their use. PHP offers many functions, so this section is larger than the rest. The third section deals with solving common programming problems such as sorting and generating graphics. The last section offers advice about how to create a whole Web site with PHP.

I've chosen a few conventions for highlighting certain information, and I'm sure you will find them obvious, but for the sake of clarity I'll spell them out. Whenever I use a keyword such as the name of a script or a function, I place it in a monospace font. For example, I may speak about the print function. Another convention I've used is to place email addresses and Web addresses inside angle brackets. Examples are the email address by which you can contact me, <corephp@leonatkinson.com>, and my Web site,

<http://www.leonatkinson.com/>

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020