PHP Montage

Master PHP Programming with Free Open-Source Books

PHP Books

PHP has been at the helm of the web for many years. It is an extremely popular, interpreted scripting language that is ideally suited for web development in part because it has an approachable syntax and supports different operating systems. This language powers millions of web sites on the net and is extremely well supported by its user community.

PHP is also used as a general-purpose programming language. PHP code can be executed with a command-line interface (CLI) and to implement standalone graphical applications. CLI PHP programs often automate common tasks such as testing, deployment, and application administration. The language offers a very complete set of object-oriented programming features as well as support for functional programming. The latest TIOBE Index ranks PHP in 7th place, behind Java, C, C++, C#, Python and Visual Basic .NET.

The language is released under a non-copyleft free software license / open source license. The latest stable version (7.1) adds lots of new features.

This compilation focuses on the PHP language with 6 strong recommendations. There are books here for beginner, intermediate, and advanced programmers. All of the texts are, of course, released under an open source license.

We have published a series covering the best open source programming books for other popular languages. Read them here.

PHP The Right Way

PHP: The Right Way

By Josh Lockhart, Phil Sturgeon (76 pages)

PHP: The Right Way is an easy-to-read, quick reference for PHP best practices, accepted coding standards, and links to authoritative tutorials around the Web. It aims to introduce new developers to some topics which they may not discover until it’s too late, and seeks to give seasoned developers some fresh ideas.

Topics covered include coding practices, dependency injection, databases, templating, errors and exceptions, security, testing, virtualization and more.

The book has been translated into German, Spanish, French, Italian, Polish, and many other languages.

The book is released under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) license. It is available to read online, and in PDF, EPUB and MOBI formats.

PHP Cookbook

PHP Cookbook

By David Sklar, Adam Trachtenberg (640 pages)

PHP Cookbook is for programmers who need to solve problems with PHP. It’s a collection of problems, solutions, and practical examples. The book contains a unique and extensive collection of best practices for everyday programming dilemmas. It contains over 250 recipes, ranging from simple tasks to entire programs that demonstrate complex tasks, such as printing HTML tables and generating bar charts — a treasure trove of useful code for programmers, from novices to advanced practitioners.

Chapters cover:

  • Strings – PHP strings differ from C strings in that they are binary-safe (i.e., they can contain null bytes) and can grow and shrink on demand
  • Numbers – integers and floating-point numbers
  • Dates and Times – looks at the mktime, date functions
  • Arrays – lists: lists of people, lists of sizes, lists of books. To store a group of related items in a variable, use an array
  • Variables – they are the core of what makes computer programs powerful and flexible
  • Functions – help you create organized and reusable code
  • Classes and Objects – a class is a package containing two things: data and methods to access and modify that data; Objects play another role in PHP outside their traditional OO position
  • Web Basics – focuses on some web-specific concepts and organizational topics that will make your web programming stronger
  • Forms – seamless integration of form variables into your programs. It makes web programming smooth and simple, from web form to PHP code to HTML output
  • Database Access – interact with 17 different databases, some relational and some not. The relational databases it can talk to are DB++, FrontBase, Informix, Interbase, Ingres II, Microsoft SQL Server, mSQL, MySQL, Oracle, Ovrimos SQL Server, PostgreSQL, SESAM, and Sybase. It communicates with dBase, filePro, HyperWave, and the DBM family of flat-file databases. It also has ODBC support
  • Web Automation – there are four ways to retrieve a remote URL in PHP
  • XML – with the help of a few extensions, read and write XML for every occasion
  • Regular Expressions – a powerful tool for matching and manipulating text
  • Encryption and Security – including obscuring data with encoding, verifying data with hashes, encrypting and decrypting data, and more
  • Graphics – with the assistance of the GD library, create applications that use dynamic images to display stock quotes, reveal poll results, monitor system performance, and even create games
  • Internationalization and Localization – create applications that speak just about any language
  • Internet Services – covers sending mail including MIME mail, reading mail with IMAP or POP3, posting and reading messages to Usenet newsgroups, getting and putting files with FTP, looking up addresses with LDAP, using LDAP for user authentication, performing DNS lookups, checking if a host is alive, and getting information about a domain name
  • Files – PHP’s interface for file I/O is similar to C’s, although less complicated
  • Directories – two ways to look in a directory to see what files it holds. The first way is to use opendir( ) to get a directory handle, readdir( ) to iterate through the files, and closedir( ) to close the directory handle. The second method is to use the directory class. Instantiate the class with dir( ), read each filename with the read( ) method, and close the directory with close( )
  • Client-Side PHP
  • PEAR – the PHP Extension and Application Repository, a collection of open source classes that work together. Developers can use PEAR classes to generate HTML, make SOAP requests, send MIME mail, and a variety of other common tasks
PHP Reference: Beginner to Intermediate PHP5

PHP Reference: Beginner to Intermediate PHP5

By Mario Lurig (164 pages)

PHP Reference Book: Beginner to Intermediate PHP5 is a collection of over 250 PHP functions with clear explanations in language anyone can understand, followed with as many examples as it takes to understand what the function does and how it works. One of the best books to keep around as a PHP reference.

This PHP reference includes numerous additional tips, the basics of PHP, MySQL query examples, regular expressions syntax, and two indexes to help you find information faster: a common language index and a function index.

Topics include:

  • Operators
  • Control Structures
  • Global Variables
  • Variable Functions
  • String Functions
  • Array Functions
  • Date/Time Functions
  • Mathematical Functions
  • MySQL Functions
  • Directory & File System Functions
  • Output Control (Output Buffer)
  • Sessions
  • Regular Expressions

This book is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 2.0 License.

PHP 5 Power Programming

PHP 5 Power Programming

By Andi Gutmans, Stig Bakken, Derick Rethans (720 pages)

In PHP 5 Power Programming, PHP 5’s co-creator and two leading developers show you how to make the most of PHP 5’s industrial-strength enhancements in any project, no matter how large or complex.

Their unique insights and realistic examples illuminate the language’s new object model, powerful design patterns, improved XML Web services support, and much more. Whether you are creating web applications, extensions, packages, or shell scripts, or migrating PHP 4 code, here are high-powered solutions you will not find anywhere else.

Review syntax and master its object-oriented capabilities, from properties and methods to polymorphism, interfaces, and reflection.

The book enables users to:

  • Master the four most important design patterns for development
  • Write powerful web applications: handle input, cookies, session extension, and more
  • Integrate with MySQL, SQLite, and other database engines
  • Provide efficient error handling that is transparent to your users
  • Leverage PHP 5’s improved XML support including parsing, XSLT conversions, and more
  • Build XML-based web services with XML-RPC and SOAP
  • Make the most of PEAR: work with the repository, use key packages, and create your own
  • Upgrade PHP 4 code to PHP 5, compatibility issues, techniques, and practical workarounds
  • Improve script performance: tips and tools for PHP optimization
  • Use PHP extensions to handle files/streams, regular expressions, dates/times, and graphics
  • Create original extensions and shell scripts

This book is part of Bruce Perens’ Open Source Series. All books in this series are released under the Open Publication License, v1.0 or later.

Practical PHP Testing

Practical PHP Testing

By Giorgio Sironi (61 pages)

This practical testing book is aimed at PHP developers and features articles from the author’s Practical PHP testing series. It also includes a chapter on TDD theory, code samples, and sets of exercises.

This book is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

Programming PHP

Programming PHP

By Wikibooks (123 pages)

Programming PHP is billed as a comprehensive guide to programming in the language. It covers the basics of the programing languages before moving on to some advanced PHP including object oriented programming, templating, libraries, frameworks, and security.

The text is available under the Creative Commons Attribution-ShareAlike License.


Here are good free-to-download programming books which are not released under an open source license.

PHP Pandas – aims to teach the reader how to be a web developer.
Hacking with PHP – has the goal of making the task of learning PHP something fun that you don’t have to worry about.
The Underground PHP and Oracle Manual – for PHP programmers developing applications for Oracle Database.
PHP Essentials – cover all aspects of PHP.


Ada, Assembly, Awk, Bash, C, C++, C#, Clojure, CoffeeScript, ECMAScript, Erlang, Forth, Fortran, Go, Haskell, HTML, Java, JavaScript, LaTeX, Lisp, Logo, Lua, OCaml, Pascal, Perl, PHP, Prolog, Python, R, Ruby, Rust, Scala, Scheme, Scratch, SQL, Swift, TeX, VimL

Click to rate this software
[Total: 0 Average: 0]

One Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.