Home Backend Development PHP Tutorial A book every PHP developer should read

A book every PHP developer should read

Aug 08, 2016 am 09:32 AM
ben database http php

  PHP has had a bad reputation in recent years. There's a lot of discussion about its "summary of bad design" and syntactic inconsistencies, but the main complaint is usually security. Many PHP sites are hacked in minutes, and even some experienced and knowledgeable programmers will say that the language itself is unsafe.

I’m always against this because there are so many PHP security violations for common sense reasons.

  PHP applications are often hacked due to:

  • There are too many PHP applications.
  • It is easy to learn and write.
  • Bad PHP is also easy to write.

 It’s that simple. PHP has been popular for many years. The more popular PHP becomes, the more vulnerabilities are discovered. The vulnerabilities discovered by these hackers are rarely in the PHP processing engine itself, but are usually weaknesses in the script itself.

 This means that when a PHP application is hacked, it is mostly the programmer's fault. Sorry, but it's true.

 You can write secure PHP just like other web languages. It's time to start really exploring security issues.

The best protection against PHP hacks

 Writing secure PHP code is not a secret black art hidden from PHP developers. But confidence is so fragmented that you need to spend weeks or months (or not) collecting some loose catalog or rule of thumb on good security practices. Only true experience will tell you how important it is.

Thankfully Ben Edmunds has done it for you. It recently published Building Secure PHP Apps – a Practical Guide, which is one of the best security-related books I’ve ever read, and certainly the best coverage of PHP. In this article I'll detail why I think every PHP developer should read it.

 This book is a concise guide that will take you to the next level as a developer, allowing you to create better and more secure scripts.

Introduction

The book quickly gets into the common sense rules of web development: don’t trust your users and filter all input. Start with a small scenario and jump to the technical methods by which users can enter the system. The themes of Chapter 1 are:

  • SQL injection
  • A large number of assignment fields
  • Type conversion
  • Filter input/output

 These are areas that PHP novices (and some veterans) have always overlooked. Filtering input is considered an optional step by many and is discussed extensively in this chapter.

While reading, I was reminded of my first day at work many years ago, when I dug deep into the existing code and found the code for the new user creation script:

?

1

2

3

if ($_POST["isadmin"] == 1) {

// code to set to admin in database

}

I panicked when I saw this code because it is a very effective script that could easily be guessed by a malicious user and insert a simple form variable to access approximately 5,000 credit card numbers and other personal information.

After digging deeper, I found the following code:

?

1

$sql = "INSERT INTO database (id,name,...) VALUES (" . $_POST["Name"] . ");"

I pretty much walked out of that job on day one because they were relying on this horrible code. The code is there, and it's your responsibility to change it to avoid creating more.

This chapter discusses why code like this is a huge risk and how to fix it.

 HTTPS and certificates

This is another area where Ben includes scripts, stories, and a bit of humor, while also clearly explaining the less clear concept of HTTPS. He explains it in a way that even your boss can understand.

 This book very comprehensively describes how certificates work, certificate types and implementation methods, even including how to deploy on Apache or Nginx.

Password

This book carefully explains passwords, hashes, lookup tables, and salts, which is incredibly helpful for developers creating user login systems.

 This is an area that was sorely lacking even in 2014. I still come across apps that store passwords in plain text or use stupid methods like ROT13 encryption to protect them. For the sake of keeping people using your app, and your good name, don't do this.

 Passwords and other sensitive data should be very difficult to obtain, and someone may even gain full access to the database. This book is very comprehensive and will give you good guidance on designing better systems.

 Authentication and access control

 The topics covered in this book are very comprehensive. When you build a new PHP application, some of the top considerations are:

  • Who can access which resources?
  • Who can control other user access?

 This is an important place to think about applications, especially applications that handle sensitive data. A considerable part of the development in the enterprise is dedicated to this. If you don't set up authentication and access control correctly, the most likely thing that will happen is that you confuse users and create more work. Even worse than this are server data gaps and/or data corruption.

This book does a good job of covering the basics, and then it dives into things like controlling access to files or individual pages of an application, with lots of code examples for reference.

 Specific use

This book covers some common exploits to compromise a system, exploring in great detail cross-site scripting, which is arguably the most common way attackers exploit applications. It explains the different kinds of attacks and how to protect yourself.

 Not bad, right? You can purchase books at a discount through this link!

What I like most about this book

What I really enjoyed while reading this book is how the information is presented in a way that is useful for both beginners and experienced programmers. There is a range of concepts presented, what they are and how to protect yourself. There are plenty of code examples, not the "padding" that some technical books have.

 You can read through this book quickly because there is not much content. Novices can read through this book, examine each topic, start looking at their code, and make corrections. Remember that in this matter, you need to keep revising. If you look back and you're ashamed of the code you wrote six months ago, you're doing the right thing.

More advanced, experienced programmers can use this guide to fill in their weaknesses (admit it, no matter how long you’ve been in this industry, you have weaknesses) and better understand the systems they use in their work. For example, I've used authentication like crazy for years, but never thought about it at the level that this book covers.

 No matter who you are, you will learn something. So stop reading this article and go buy a copy! Use this link to purchase and get a discount! !

Disclaimer

 I haven’t commented much on my blog, so you may have some questions. For clarity, I was not paid or compensated for the review. The coupon code above gives readers of my blog $4 off the original book price, and I will not receive any money. Of course I received a promotional copy of this book for review purposes.

I know this author personally, which is one of the reasons why I trust the information in this book and completely trust his guidance. Ben Edmunds has had a huge influence in the PHP community in recent years. He has 10 years of experience in PHP. He is one of the leaders of the PHP User Group in Poland. He has made great contributions to the PHP open source project in recent years. Suffice it to say, he knows his stuff and you can trust the information presented here.

  • Original address: http://www.jeremymorgan.com/blog/programming/the-book-every-php-dev-should-read/
  • Note 1: ROT13 (rotate by 13 places, sometimes called ROT-13 with a hyphen in the middle) is a simple replacement password. http://zh.wikipedia.org/wiki/ROT13

The above introduces the books that every PHP developer should read, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1672
14
PHP Tutorial
1276
29
C# Tutorial
1256
24
PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP: Handling Databases and Server-Side Logic PHP: Handling Databases and Server-Side Logic Apr 15, 2025 am 12:15 AM

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

See all articles