Download the php language tutorial

According to the agreement between publishing house "Williams" and the Internet Store "Books.Ru - Books of Russia" is the only legal way receiving this file with the book “PHP 5 for Beginners” (ISBN 5-8459-1039-0) – purchase on the Internet

store "Books.Ru - Books of Russia".

If you received this file In any other way, you have violated copyright laws. You need to delete this file and also inform publishing house "Williams" where exactly did you get this file?

BBK 32.973.26 018.2.75 M52

Computer publishing house ''Dialectics''

Head edited by S.N. Trigub

Translation from English by V.A. Shvetsa

By general issues Please contact the publishing house “Dialectics” at: [email protected], http://www.dialektika.com

115419, Moscow, PO Box 783; 031150, Kyiv, PO Box 152

Mercer, Dave W., Kent, Allan, Nowitzki, Stephen, Mercer, David, Squier, Dan, Choi, Wang Q.

M52 PHP 5 for beginners. : Per. from English M.: LLC I.D. ‘‘Williams’’, 2006. 848 p. : ill. Parall. tit. English

ISBN 5 8459 1039 0 (Russian)

This book is a detailed tutorial for those who want to master modern version PHP. The book covers installing and configuring PHP, basic programming concepts such as variables, loops, conditionals and arrays, and the basics of object-based programming. oriented programming and how it can be used in PHP 5. It also covers topics such as working with HTTP data from PHP, using XML, RDBMS (MySQL and SQLite), working with images, and PHP creation scenarios command line. In addition, the book describes application design using UML, PEAR packages and techniques for reusing PHP code, as well as error handling, testing and debugging applications.

BBK 32.973.26 018.2.75

All titles software products are registered trademarks from the relevant companies.

No part of this publication may be reproduced in any form or by any means, electronic or mechanical, including photocopying or recording, for any purpose, without permission in writing from JOHN Publishers. WILEY&SONS, INC.

Copyright © 2006 by Dialektika Computer Publishing.

Original English language edition Copyright © 2004 by Wiley Publishing, Inc., Indianapolis, Indiana.

All rights reserved including the right of reproduction in whole or in part in any form. This translation published by arrangement with Wiley Publishing, Inc.

Wiley, the Wiley Publishing logo, Wrox, the Wrox logo, and Programmer to Programmer are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.

Introduction

Chapter 4. Logical operators, loops and arrays

Chapter 7. Files and Directories

Chapter 8. XML

Chapter 9: Introduction to Databases and SQL

Chapter 10: Retrieving Data from MySQL Using PHP

Chapter 11. Using PHP for information management

in MySQL databases

Chapter 12. Introduction to Object Orientation

programming

Chapter 13: Working with UML and Classes

Chapter 14

Chapter 15. PHP5 and Email

Chapter 16: Generating Graphics

Chapter 17. Tutorial example: PHP logging manager

Appendix A. Answers

Appendix B. PHP*Functions Reference

Appendix B: Using SQLite

Appendix D. ODBC

Appendix E. CLI*PHP interface

Appendix E. PHP5 Configuration

Subject index

Introduction

Why PHP?

Who is this book for?

Topics covered in this book

How is this book organized?

What is required to use this book

Using the Command Line

Agreements

Source

Chapter 1. Installing and Using PHP

Origins of PHP

Installing, configuring and running PHP

System requirements

Configuration PHP file, php.ini

Setting up a test machine

Network connections

Where to begin?

Using PHP 5

Installing PHP on Linux and Apache

Selecting an installation method

RPM+install PHP 4

Compiling PHP 5 from source code

Configuring Apache to work with PHP

Configuring Apache to work with PHP 5

Starting or restarting Apache

Installing PHP 5 on Windows 2000/Internet Information Server 5

php.ini and extensions

Testing and Troubleshooting

PHP Configuration

php.ini file

PHP+extensions

Caching

Exercises

Chapter 2: Writing Simple Programs

Creating PHP+programs

Some components

How PHP+code works

Web+page (user interface)

File extensions

PHP+delimiters

Correct PHP+code

Common markers in code

How PHP+ programs work in the Web+ environment

Web+connections: Internet+protocols and HTTP

HTTP+protocol

HTTP+request

Response body

Running PHP+scripts via HTTP+request

Web+server

PHP+processor

Using Variables in PHP

Creating Variables

Naming Variables

Data types

Variable scope

Keyword global

Static Variables

Definition of constants

Operators and Expressions

PHP+operators

PHP+expressions

Operator types

String Operators and Functions

How it works

Arithmetic operations in PHP

How it works

Array indexes

Using Strings as Array Indexes

Initializing Arrays

Working with Arrays

Sorting arrays using the sort() and asort() functions

Exercises

Chapter 3. PHP, HTML and Session State

HTML Basics

form and input descriptors

8 Contents

Access to PHP+ and HTTP+ data

Predefined Variables

Variables in HTTP+ requests and responses

How it works

Superglobal arrays

Query strings

HTML+forms (or Web+forms)

HTML+form descriptors

Descriptor

Descriptor Attributes

URL+encoding

PHP and HTML+form fields (controls)

Text fields (text windows)

How it works

Why this example might not work

Text area

How it works

How it works

Using Multiple Checkboxes

How it works

Switches

How it works

How it works

Hidden form fields

How it works

Password fields

Submit and reset buttons

Using return values ​​in PHP+scripts

How it works

Possible app improvements

State concept

Condition monitoring

Hidden form fields

Query strings

Database

Cookies+files

How it works

Native sessions in PHP

How it works

Exercise

Writing pseudocode

Boolean logic

Boolean terms

Boolean values

Using Boolean Terms and Values

Conditional or branch statements

Branching example

if statement

Using Boolean Operators in Structures

control logic

Operators > and<

How it works

Operators == and ===

Operators != and<>

How it works

Logical operators (AND, OR, !)

How it works

Switch statements

How it works

Loops and Arrays

How it works

Infinite loops

do while loops

How it works

How it works

Initializing Arrays

Iterations in an array

How it works

Program improvement

Iterating on Unordered Arrays

current() and key() functions

next() and prev() functions

list() and each() functions

Iterations in associative arrays

Sorting Arrays

sort() function

asort() function

rsort() and arsort() functions

ksort() function

Multidimensional arrays

Practical use of arrays

How it works

array_multisort() function

Chapter 5. Reliable and understandable code

Testing and Debugging

Values ​​that break code

Main types of errors

Debugging PHP+script

PHP Error Messages

Configuring PHP for Error Handling

Types of errors in PHP

Syntax errors

Logical errors

Runtime errors

Division by zero

Infinite loops

Logical output errors

Assigning values ​​instead of comparing values

Debugging and error handling in PHP5

Prevent the display of sensitive information

Creating Your Own Debugging Tools

Using the echo() operator

Errors inside HTML+code

Validation of form data

Using the exit statement

How it works

Prevent user from entering HTML+ code: function

HTMLSpecialChars()

String Validation and Regular Expressions

Checking strings

Regular Expressions

Using the ereg() function

Special symbols

Some common patterns and their variations

Validation of data entry

How it works

Using Regular Expressions for Validation

URL+pointers

How it works

Using Regular Expressions to Validate Parameters

file paths

How it works

Graceful error handling

Configuring Error Handling in PHP

Suppressing Error Messages

Checking the Error Log

Try/Catch ++++++ innovations in PHP5

How it works

Exercise

Chapter 6: Creating High-Quality Code

Development planning

Formal software development process

Writing a specification

Code writing process

Testing, debugging and maintenance

Code optimization

Using coding standards

Writing Custom Functions in PHP

Function structure

Defining and calling functions

How it works

Switching functions

How values ​​get into functions

Pass by value

Setting Defaults

The importance of argument order

Variable Scope

Global and local variables

Creating Static Variables in Functions

How it works

Function nesting

Recursion

How it works

include and require statements

How it works

Things to take care of when using include files

Exercise

Chapter 7. Files and Directories

Processing files and directories

Working with files

Opening and closing files

fopen() function

fclose() function

Getting information about a file

Reading and writing files

fread() function

fwrite() function

How it works

Custom functions for working with files

Separating filename and path

Copying, renaming and deleting files

Working with catalogs

How it works

Other directory processing functions

Directory tree traversal

Directory navigation script

Creating a Text Editor

How it works

Exercise

Chapter 8. XML

What is XML

XML+document structure

Main parts of an XML+ document

Well-formed XML+documents

Using XML+elements and attributes

Correct XML+documents: DTD+definitions and XML+schemas

DTD+definition for XHTML

External XML+schemas

Writing XML+Documents Using XHTML

Web+services

XML+functions in PHP4

How it works

XML+analyzers

How it works

Document object model

DOM+extension

Using DOM functions + PHP extensions

XML+PHP5 functions

SimpleXML extension

Using the simplexml_load_string() function

Using the simplexml_load_file() function

The selection includes books both for those who have experience with this language and for beginners. One thing to remember is that you don't always have to be familiar with programming using PHP. Therefore, if you choose it as your first language, then this should be an informed decision and it is better to do it in conjunction with the study of other technologies. It will help you make your choice.

« PHP, in my opinion, is not the best to start learning programming. It is good and powerful for its purposes. This is not my first programming language, so learning it did not require a lot of effort and books. I learned PHP first on my own, using various sites with reference materials, then taking courses, and then again using sites. I mainly used the manual on php.net from the creators"- says Vladimir Vashchenko, Senior Developer at Sevmorgeo.

PHP, MySQL, JavaScript & HTML5 All-in-One For Dummies (Steve Suehring)

For those who chose PHP as their first language to learn. The book from the famous publishing house O"Reilly reveals the essence of key web technologies. Here is everything you need to know to get started about creating dynamic web pages that run on MySQL. Unfortunately, there are inaccuracies in the code examples, but broken examples can be compensated simply by Googling .

Learning PHP and MySQL (Lynn Bailey)

Suitable for beginners, but before reading it is better to have skills in working with html. The book provides simple and understandable examples, sequentially covering topics from elementary to advanced. The book is designed in an interesting visual format that will not let you get bored, and contains many exercises.

Learning PHP, MySQL, & JavaScript 4th Edition (Robin Nixon)
in Russian 3rd edition

Comprehensive and up-to-date, the book is suitable for beginners, but will also be useful for those with experience working with these technologies. This best-selling book explains each one, shows how to combine them, and covers the most important concepts in modern web development.

More complicated

PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (Larry Ullman)

A book for understanding OOP in PHP. Unlike many “techies,” the author writes in an accessible manner and cares so much about his readers that he personally answers questions that arise during reading on his forum.

PHP. Objects, Patterns, and Programming Techniques (Mat Zandstra)

A must read for those who want to become a pro. The book is suitable for Junior level and will be useful for those who are tired of writing in a procedural style. In principle, it will be useful not only for PHP programmers. Design and development approaches are described here in a very clear way. The author covers OOP in all its glory, and the patterns shown in the book allow you to “work wonders.” One of the goodies is working with git.

Bonus

Domain-Driven Design (DDD) (Eric Evans)

Worth reading for anyone dealing with OOP. The book expands the understanding of both design patterns and application architecture, offering something more than the usual OOP. The examples in the book in a C-like language will be understandable to any programmer.

If you are a beginner, take on a simple project as soon as possible: a business card website, a small online store. Once you reach expert “status,” don’t forget to follow the official documentation.

And for those who want to develop professionally in PHP, we recommend the profession.

Digest of current materials for learning PHP 7: books, video tutorials and online courses for specialists of different levels of training.

For in-depth study

PHP. The right way

An easy-to-follow, comprehensive guide to PHP that introduces the reader to effective use of the language and its standards.
The manual is accompanied by links to authoritative sources and recognized guides throughout the Internet, which significantly expands the scope of language learning.
This resource has been translated into several languages, including Russian, Japanese, Chinese, Italian, Spanish and German. It is entirely freely available and allows you to not only use it for free, but also contribute to it using GitHub.

M. Zandstra “PHP. Objects, patterns and programming techniques" (2016)


The book includes a detailed overview of PHP's object-oriented features: defining classes, inheritance, encapsulation, and more. You will also learn some basic design techniques.
The second part of the book is devoted to design patterns, examining their concepts, implementation methods, and applications.
The last part of the book describes several important utilities and techniques that help you create a successful project from disparate pieces of code. This part of the book describes how to manage multiple programmers using Git, how to build and deploy a project using Phing and PEAR.
You will also learn the basics of automated testing and project building.

D. Koterov, I. Simdyanov “PHP 7. The most complete guide” (2016)


This book covers the basics of the PHP language and its working environment on different operating systems.
The radical changes in the PHP language that have occurred since the release of the previous edition are reflected: traits, namespaces, anonymous functions, closures, strongly typed elements, generators, a built-in Web server and many other features. A description of the syntax of PHP 7 is provided, as well as functions for working with arrays, files, the MySQL DBMS, memcached, regular expressions, graphic primitives, mail, sessions, and so on.
Particular attention is paid to the working environment: the assembly of PHP-FPM and the nginx Web server, the MySQL DBMS, the SSH protocol, VirtualBox virtual machines and the Vagrant virtual machine manager.
The publication describes the most modern approaches to web development. The publisher's website contains the source codes for all listings.

PHP programming language - Training course - Savelyeva N.V. - 2006.

PHP is currently one of the most popular languages ​​for implementing web applications. This course is devoted to studying its basics. The emphasis is on the practical application of acquired skills.
The PHP language was created to solve a specific practical problem on the Internet (which one can be found out by reading the first lecture of the course). We will also try not to be distracted too much by theoretical reasoning, and will strive to solve a specific problem in each of the lectures. Most of the examples are taken from a real-life system: a virtual museum of the history of computer science. The first part of the course is devoted to studying the basics of syntax and control structures. After this, client-server technology is considered as the main application area of ​​the PHP language. Then we move on to studying the most useful built-in functions in our opinion and solving practical problems with their help. Although the object model in the PHP language is not the richest, its fundamental presence allows you to naturally describe object data models. As a basic model, the document model of a virtual computer science museum will be considered. After this, a number of applied aspects will be considered: working with the file system, with the database, strings, sessions, DOM XML - all this will allow us to consider the key tasks of the practical use of the language.

PHP, MySQL for beginners - Andy Harris - 2005.

This book will help you learn how to program in PHP and create databases in MySQL. If your goal is to write programs for web servers, then this book is for you. You will learn all the basic concepts of programming languages, in particular, learn the commands and syntax of the PHP language. You will also learn how data is used in modern environments, in addition to all this, you will also learn the programming process itself.


Download and read PHP, MySQL for beginners - Andy Harris

PHP - Learning by Example - Kuharchik A.

PHP - Learning by Example - Kukharchik A. - 2004.

The basics of PHP, a popular language for writing scripts for Web pages, are presented in a simple and accessible way. By completing simple examples, the reader will be able to master the basics of programming in PHP, create a dynamic page, a site visit counter, a voting system, an address book, and an online store. Typical errors in using scripts are described, as well as ways to correct them. The book contains code snippets that you can use to create your own projects.

Intended primarily for beginners, but can also be useful for experienced programmers using PHP.