PHP y MySQL
¡Sumérgete en el desarrollo web con esta completa guía de PHP 8! Tanto si eres principiante como desarrollador experimentado, encontrarás todo lo que necesitas para crear sitios web dinámicos y seguros. Aprende a instalar PHP, a programar orientado a objetos y a trabajar con bases de datos como MySQL. Adquiere experiencia práctica con código detallado y ejemplos de aplicaciones. ¡Domina temas avanzados como la depuración, las pruebas automatizadas, la seguridad y mucho más!
- Tu guía completa para el desarrollo web del lado del servidor con PHP
- Aprenda los conceptos básicos de la programación PHP, desde la sintaxis y las cadenas hasta las funciones y las expresiones regulares, antes de sumergirse en las técnicas web.
- Utilice PHP con bases de datos populares: MySQL, PDO, SQLite, Oracle, MongoDB y muchas más.
Aprenderás sobre:
- Conceptos básicos de PHP:
Recorra los primeros pasos del uso de PHP, desde la instalación hasta la selección del sistema de base de datos (SQLite, Microsoft SQL Server, PostgreSQL y más). Obtenga una introducción completa al lenguaje, incluidas todas las nuevas características de PHP 8.
- Desarrollo web:
Aprenda a utilizar PHP junto con importantes tecnologías web, como formularios, sesiones, cookies y correos electrónicos. Realice tareas comunes con las que se encontrará como programador PHP utilizando código detallado y ejemplos de aplicaciones.
- Comunicación segura de bases de datos:
Interactúa con JavaScript y accede a servicios web a través de HTTP. Evita riesgos de seguridad mediante la autenticación de usuarios y aprende técnicas que te ayudarán a proteger tu sitio web, como el cross-site scripting (XSS) y las inyecciones SQL.
Aspectos Destacados:
- Instalación
- Cadenas, matrices y expresiones regulares
- Funciones matemáticas y de fecha
- Técnicas web
- Bases de datos
- Programación orientada a objetos
- Espacios de nombres
- Patrones de diseño
- XML, gráficos y PDF
- Administración y seguridad
- Depuración
- Pruebas automatizadas
Ver Tabla de Contenidos Completa
PHP and MySQL
Dive into web development with this comprehensive guide to PHP 8! Whether you’re a beginner or an experienced developer, you’ll find everything you need to build dynamic, secure websites. Walk through installing PHP, object-oriented programming, and working with databases like MySQL. Gain hands-on experience with detailed code and application examples. Master advanced topics like debugging, automated testing, security, and more!
- Your complete guide to server-side web development with PHP
- Learn the basics of PHP programming, from syntax and strings to functions and regular expressions, before diving into web techniques
- Use PHP with popular databases: MySQL, PDO, SQLite, Oracle, MongoDB, and more
You'll learn about:
- PHP Basics:
Walk through the first steps of using PHP, from installation to database system selection (SQLite, Microsoft SQL Server, PostgreSQL, and more). Get a complete introduction to the language, including all the new features of PHP 8.
- Web Development:
Learn how to use PHP in conjunction with important web technologies, including forms, sessions, cookies, and emails. Perform common tasks you’ll encounter as a PHP programmer using detailed code and application examples.
- Secure Database Communication:
Interact with JavaScript and access web services via HTTP. Avoid security risks through user authentication and learn techniques to help secure your website, such as cross-site scripting (XSS) and SQL injections.
Key Highlights:
- Installation
- Strings, arrays, and regular expressions
- Mathematical and date functions
- Web techniques
- Databases
- Object-oriented programming
- Namespaces
- Design patterns
- XML, graphics, and PDFs
- Administration and security
- Debugging
- Automated testing
View Full Table of Contents
- Preface
- Materials for the Book
- The Concept
- The Content
- About the PHP 8.3 Edition
- Support
- PART I Preparations
- 1 Introduction to PHP
- 1.1 History of PHP
- 1.2 Success and Commitment
- 1.3 The Concept of PHP
- 1.4 The Most Important New Features in PHP 8 to 8.4
- 1.5 The Most Important Features in PHP 7.3
- 1.6 The Most Important Features in PHP 7
- 1.7 The Most Important Features in PHP 5.4, 5.5, and 5.6
- 1.8 Downloads and Documentation
- 2 Installation
- 2.1 Install PHP
- 2.1.1 Structure of PHP
- 2.1.2 Windows
- 2.1.3 macOS
- 2.1.4 Linux
- 2.2 PEAR
- 2.2.1 Install PEAR
- 2.2.2 PEAR Packages without Installation
- 3 Testing and Help
- 3.1 Common Errors
- 3.1.1 The Page Cannot Be Displayed
- 3.1.2 The Website Was Not Found—File Not Found
- 3.1.3 Server Not Found
- 3.1.4 Unable to Initialize Module
- 3.1.5 Module Not Found
- 3.1.6 The Browser Opens a Download Window
- 3.1.7 No Input File Specified (or Something Similar)
- 3.1.8 Call to Undefined Function
- 3.1.9 Internal Server Error
- 3.1.10 VCRUNTIME140.DLL Is Missing
- 3.1.11 White Page in the Browser
- 3.1.12 Extension Does Not Appear in phpinfo()
- 3.2 Additional Resources
- PART II Getting Started with PHP
- 4 PHP Language Basics
- 4.1 PHP in HTML
- 4.1.1 Comments
- 4.1.2 Instructions
- 4.1.3 External File
- 4.2 Output with PHP
- 4.2.1 Abstract
- 4.2.2 Quotation Marks
- 4.3 Variables
- 4.3.1 Data Types
- 4.3.2 Naming
- 4.3.3 Variable Variables
- 4.3.4 Output Variables
- 4.3.5 Useful and Helpful Information
- 4.3.6 Predefined Variables
- 4.4 Constants
- 5 Programming
- 5.1 Operators
- 5.1.1 Arithmetic Operators
- 5.1.2 Comparison Operators
- 5.1.3 Logical Operators
- 5.1.4 Binary Numbers and Bitwise Operators
- 5.1.5 Operators that Step out of Line
- 5.1.6 Ranking of the Operators
- 5.2 Case Distinctions
- 5.2.1 ""if""
- 5.2.2 ""switch""
- 5.2.3 ""match""
- 5.3 Loops
- 5.3.1 ""for""
- 5.3.2 ""while""
- 5.3.3 ""do-while""
- 5.4 Jumps
- 6 Functions and Language Constructs
- 6.1 Functions
- 6.1.1 Parameters
- 6.1.2 Validity of Variables
- 6.1.3 Return Value
- 6.1.4 Function Names in Variables
- 6.1.5 Anonymous Functions
- 6.1.6 Recursive Functions
- 6.1.7 Type Declarations
- 6.1.8 Enumerations
- 6.1.9 Helpful and Useful Information
- 6.1.10 Functions of PHP
- 6.2 Language Constructs
- 6.2.1 ""heredoc""
- 6.2.2 ""nowdoc""
- 6.2.3 Formatted Strings
- 6.2.4 ""print_r"" and ""var_dump""
- 7 Strings
- 7.1 Connect
- 7.2 Splitting and Joining
- 7.2.1 Accessing Characters
- 7.2.2 Interrupt Evenly
- 7.2.3 Line Breaks
- 7.2.4 Split into Strings
- 7.2.5 Strings and Arrays
- 7.3 Upper- and Lowercase
- 7.4 Pruning
- 7.4.1 Cut Out Characters
- 7.4.2 Remove Whitespaces
- 7.5 Search and Replace
- 7.5.1 Search
- 7.5.2 Replace
- 7.6 Special Characters, HTML, and the Like
- 7.6.1 Escaping for Databases
- 7.6.2 Escaping for Regular Expressions
- 7.6.3 HTML
- 7.6.4 URLs
- 7.7 Compare
- 7.7.1 Comparison Functions
- 7.7.2 Similarities and Differences
- 7.7.3 Pronunciation
- 7.8 Helpful and Useful Information
- 7.8.1 ASCII and Conversion
- 7.8.2 Unicode Code Point
- 7.8.3 Encryption
- 7.8.4 Turn Over
- 7.8.5 Multibyte String Functions
- 8 Arrays
- 8.1 Basics
- 8.1.1 Create Arrays
- 8.1.2 Adding and Changing Elements
- 8.1.3 Delete Elements
- 8.1.4 Associative Arrays
- 8.1.5 Shorthand with JSON
- 8.1.6 Multidimensional Arrays
- 8.2 Arrays and Loops
- 8.2.1 ""for""
- 8.2.2 ""foreach""
- 8.2.3 Functions for Iteration
- 8.3 Examine
- 8.4 Transform
- 8.4.1 Adding and Removing
- 8.4.2 Delete and Replace
- 8.4.3 Connect
- 8.4.4 Variables and Arrays
- 8.4.5 Dereferencing
- 8.4.6 Conversion to Parameters
- 8.5 Search and Sort
- 8.6 Superglobal Arrays
- 9 Mathematical and Date Functions
- 9.1 Math
- 9.1.1 Basics
- 9.1.2 Constants
- 9.1.3 Convert Numbers
- 9.1.4 Random Numbers
- 9.1.5 Maximum, Minimum, and Rounding
- 9.1.6 Radians and More
- 9.1.7 Higher Accuracy
- 9.2 Date and Time
- 9.2.1 Current Date with Functions
- 9.2.2 Current Date with ""DateTime""
- 9.2.3 Any Date Values
- 9.2.4 Timestamp
- 9.2.5 Format Date
- 9.2.6 Countdown: Calculate with Dates
- 10 Regular Expressions
- 10.1 Basics
- 10.2 Functions for Regular Expressions
- 10.2.1 ""preg_match()""
- 10.2.2 Further Functions
- 10.2.3 Reuse Replacement Strings
- 10.2.4 Modifiers for Search Patterns
- 10.3 Application Examples
- 10.3.1 Zip Codes
- 10.3.2 Telephone and Fax Numbers
- 10.3.3 Filter Links
- 11 Object-Oriented Programming
- 11.1 History of Object Orientation in PHP
- 11.2 Classes and Objects: Basic Concepts
- 11.2.1 Classes and Objects in PHP
- 11.2.2 Properties
- 11.2.3 Methods
- 11.2.4 Inheritance
- 11.3 Advanced
- 11.3.1 Clone Objects
- 11.3.2 Constructor
- 11.3.3 Destructor
- 11.3.4 Private, Protected, and So On
- 11.3.5 Interfaces
- 11.3.6 Late Static Binding
- 11.3.7 Abstract Classes
- 11.3.8 Anonymous Classes
- 11.3.9 Constants
- 11.3.10 Overloaded
- 11.3.11 Traits
- 11.4 Helpful and Useful Information
- 11.4.1 Error Level
- 11.4.2 ""spl_autoload_register()""
- 11.4.3 ""__METHOD__""
- 11.4.4 ""__toString()""
- 11.4.5 Class Types and ""instanceof""
- 11.4.6 Compare Objects
- 11.4.7 Serialize Objects
- 11.4.8 Automated Reading of Objects
- 11.4.9 Iteration
- 11.4.10 Reflection API
- 11.4.11 SPL
- 11.4.12 Native Metadata with Attributes
- 11.5 Namespaces
- 11.5.1 Why Namespaces?
- 11.5.2 Working with Namespaces
- 11.5.3 Use Namespaces
- 11.5.4 Determine the Current Namespace
- 11.5.5 Namespaces via Alias
- 12 Design Patterns: MVC and Co.
- 12.1 Laminas
- 12.2 MVC
- 12.3 Adapter and Factory
- PART III Web Techniques
- 13 Forms
- 13.1 Preparations
- 13.2 Forms with PHP
- 13.2.1 The “Good” Old Days
- 13.2.2 HTTP Methods
- 13.2.3 Text Field(s)
- 13.2.4 Radio Buttons
- 13.2.5 Checkboxes
- 13.2.6 Selection Lists
- 13.2.7 Determine the HTTP Method
- 13.3 Form Validation
- 13.3.1 Text Field(s)
- 13.3.2 Radio Buttons
- 13.3.3 Checkboxes
- 13.3.4 Selection Lists
- 13.3.5 More Detailed Error Messages
- 13.4 Prefill
- 13.4.1 Preparations
- 13.4.2 Text Fields
- 13.4.3 Radio Buttons
- 13.4.4 Checkboxes
- 13.4.5 Selection Lists
- 13.5 File Uploads
- 13.6 Application Examples
- 13.6.1 JavaScript Form Check
- 13.6.2 Picture Gallery
- 13.7 Settings
- 14 Cookies
- 14.1 Preparations
- 14.2 Facts and Background
- 14.2.1 What Is a Cookie?
- 14.2.2 Restrictions
- 14.2.3 The Transparent Surfer?
- 14.3 Working with Cookies in PHP
- 14.3.1 Set Cookies
- 14.3.2 Read Cookies
- 14.3.3 Delete Cookies
- 14.3.4 ""New"" Cookies
- 14.4 Cookie Test
- 14.5 Final Considerations
- 15 Sessions
- 15.1 Preparations
- 15.2 Facts, Background, and Configuration
- 15.2.1 Keep Data
- 15.2.2 Performance
- 15.3 Working with Sessions in PHP
- 15.3.1 Write Data
- 15.3.2 Read Out Data
- 15.3.3 Delete Data
- 15.3.4 Configure Sessions
- 15.4 Protected Area
- 15.5 Sessions in Databases
- 15.6 Security Concerns
- 15.6.1 No Sessions without Cookies!
- 15.6.2 Check the Referrer
- 15.6.3 Change the Session ID
- 15.6.4 Making Cross-Site Request Forgery More Difficult
- 15.6.5 Prevent JavaScript Access to the Session Cookie
- 16 Email
- 16.1 Preparations
- 16.2 Sending Mails with PHP
- 16.2.1 Standard Mails
- 16.2.2 MIME Mails
- 16.2.3 IMAP and POP
- PART IV Databases
- 17 SQL
- 17.1 Create Databases and Tables
- 17.1.1 Primary Key
- 17.1.2 Data Types
- 17.2 Enter Data
- 17.3 Query Data
- 17.4 Update Data
- 17.5 Delete Data
- 17.6 Special Features
- 17.6.1 Relational Database Design
- 17.6.2 Joins
- 17.6.3 Aggregate Functions
- 17.6.4 Transactions
- 17.6.5 Stored Procedures
- 18 PDO
- 18.1 Preparations
- 18.2 Database Access with PDO
- 18.2.1 Connection Setup
- 18.2.2 Queries
- 18.2.3 Return Values
- 18.2.4 Special Features
- 18.3 Guestbook
- 18.3.1 Create Table
- 18.3.2 Enter Data
- 18.3.3 Output Data
- 18.3.4 Delete Data
- 18.3.5 Edit Data
- 19 MySQL
- 19.1 Preparations
- 19.2 Database Access with MySQL
- 19.2.1 Connection Setup
- 19.2.2 Queries
- 19.2.3 Return Values
- 19.2.4 Special Features
- 19.3 Application Example
- 19.3.1 Create Table
- 19.3.2 Enter Data
- 19.3.3 Output Data
- 19.3.4 Delete Data
- 19.3.5 Edit Data
- 19.4 Settings
- 20 SQLite
- 20.1 Preparations
- 20.2 Database Access with SQLite
- 20.2.1 Connection Setup
- 20.2.2 Queries
- 20.2.3 Return Values
- 20.2.4 Special Features
- 20.2.5 Migration of Old Code
- 20.3 Application Example
- 20.3.1 Create Table
- 20.3.2 Enter Data
- 20.3.3 Output Data
- 20.3.4 Delete Data
- 20.3.5 Edit Data
- 21 Microsoft SQL Server
- 21.1 Preparations
- 21.2 Microsoft SQL Server Driver for PHP
- 21.2.1 Connection Setup
- 21.2.2 Queries
- 21.2.3 Return Values
- 21.2.4 Special Features
- 21.3 Application Example
- 21.3.1 Create Table
- 21.3.2 Enter Data
- 21.3.3 Output Data
- 21.3.4 Delete Data
- 21.3.5 Edit Data
- 22 Oracle
- 22.1 Preparations
- 22.2 Database Access with Oracle
- 22.2.1 Connection Setup
- 22.2.2 Queries
- 22.2.3 Return Values
- 22.2.4 Special Features
- 22.3 Application Example
- 22.3.1 Create Table
- 22.3.2 Enter Data
- 22.3.3 Output Data
- 22.3.4 Delete Data
- 22.3.5 Edit Data
- 23 PostgreSQL
- 23.1 Preparations
- 23.2 Database Access with PostgreSQL
- 23.2.1 Connection Setup
- 23.2.2 Queries
- 23.2.3 Return Values
- 23.2.4 Special Features
- 23.3 Application Example
- 23.3.1 Create Table
- 23.3.2 Enter Data
- 23.3.3 Output Data
- 23.3.4 Delete Data
- 23.3.5 Edit Data
- 23.4 Settings
- 24 MongoDB
- 24.1 Preparations
- 24.2 Database Access with MongoDB
- 24.2.1 Connection Setup
- 24.2.2 Insert
- 24.2.3 Queries and Return Values
- 24.2.4 Refresh
- 24.2.5 Delete
- 24.3 Application Example
- 24.3.1 Create Data Memory
- 24.3.2 Enter Data
- 24.3.3 Output Data
- 24.3.4 Delete Data
- 24.3.5 Edit Data
- 24.4 Settings
- PART V Communication
- 25 Files
- 25.1 Preparations
- 25.2 File Handling with PHP
- 25.2.1 Working with Files
- 25.2.2 Working with the File System
- 25.3 Application Examples
- 25.3.1 Guestbook
- 25.3.2 File Browser
- 25.4 Settings
- 26 HTTP and Beyond: Connections to the Outside World
- 26.1 Preparations
- 26.2 External Connection with PHP
- 26.2.1 Streams
- 26.2.2 HTTP Streams
- 26.2.3 PHP Streams
- 26.2.4 Compression Streams
- 26.3 Fibers
- 26.4 Application Examples
- 26.4.1 Text Versions of Web Pages
- 26.4.2 Online Compressor
- 27 APIs and Services
- 27.1 Preparation
- 27.1.1 Web Services Basics
- 27.1.2 Installation
- 27.2 REST
- 27.3 nuSOAP
- 27.3.1 Server
- 27.3.2 Client
- 27.3.3 WSDL
- 27.3.4 Conclusion
- 27.4 PHP-SOAP
- 27.4.1 Server
- 27.4.2 Client
- 27.4.3 WSDL
- 27.4.4 Conclusion
- 28 JavaScript
- 28.1 Preparations
- 28.2 Connecting JavaScript with PHP
- 28.2.1 Reading PHP Variables with JavaScript
- 28.2.2 Reading JavaScript Variables with PHP
- 28.3 Ajax
- 28.4 WebSockets
- 28.4.1 Server
- 28.4.2 Client
- PART IV Data Formats
- 29 XML
- 29.1 Preparations
- 29.1.1 XML Basics
- 29.1.2 Installation
- 29.2 XML Access
- 29.2.1 SAX
- 29.2.2 SimpleXML
- 29.2.3 DOM Access
- 29.2.4 Validation
- 29.2.5 XSLT
- 29.3 XMLReader and XMLWriter
- 29.3.1 XMLReader
- 29.3.2 XMLWriter
- 29.4 EXIF
- 29.4.1 Preparation
- 29.4.2 Implementation
- 30 Graphics with PHP
- 30.1 Preparations
- 30.2 GD 2 in Action
- 30.2.1 Basic Framework
- 30.2.2 Text
- 30.2.3 Shapes
- 30.2.4 Lines and Styles
- 30.2.5 Output of the Images
- 30.2.6 Image Processing
- 30.2.7 Dynamic Diagram
- 30.3 The Alternatives
- 30.3.1 ImageMagick
- 30.3.2 GraphicsMagick
- 30.3.3 NetPBM
- 31 PDF with PHP
- 31.1 Preparation
- 31.1.1 TCPDF
- 31.1.2 FPDF
- 31.1.3 Haru
- 31.2 TCPDF
- 31.2.1 Basics
- 31.2.2 Cells
- 31.2.3 Lines and Points
- 31.2.4 Pie Chart
- 31.2.5 Write HTML
- 31.3 FPDF
- 31.3.1 Basics
- 31.3.2 Drawing
- 31.4 Conclusion
- PART VII Administration and Security
- 32 Security
- 32.1 User Input
- 32.2 XSS
- 32.3 SQL Injection
- 32.4 Hidden Fields
- 32.5 Input Filter
- 32.6 Cross-Site Request Forgery
- 32.7 Screen Scraping and Captchas
- 32.8 Encrypt Passwords
- 33 Authentication
- 33.1 Apache Authentication
- 33.2 IIS Authentication
- 33.3 HTTP Authentication by Hand
- 33.4 Standards-Based Authentication
- 33.4.1 Preparation of the Google Project
- 33.4.2 Access via PHP
- 33.5 Conclusion
- 34 Configuration Options in php.ini
- 34.1 Where to Configure?
- 34.1.1 Storage Location
- 34.1.2 Other Configuration Files
- 34.2 Configure What?
- PART VIII Beyond PHP
- 35 Troubleshooting with Xdebug
- 35.1 Debugging by Hand
- 35.2 Debugging with Xdebug
- 35.3 Resolution
- 36 Unit Tests with PHPUnit
- 36.1 Unit Tests
- 36.2 Install PHPUnit
- 36.3 Testing with PHPUnit
- 37 Apache Functions
- 37.1 Preparations
- 37.2 Application Examples
- 37.2.1 Information about Apache
- 37.2.2 Reading HTTP Headers
- 37.2.3 URI Information
- 37.2.4 Integrate Other Server Technologies
- 37.2.5 Terminate Apache Process
- 38 Composer
- 38.1 Install Composer
- 38.2 Install Packages via Composer
- 38.3 Customize Your Own Code for Composer
- 39 PHP Extensions
- 39.1 Programming
- 39.2 Compile
- 39.3 Testing
- 40 Contribute to PHP
- 40.1 Patches for PHP
- 40.1.1 Bug Fix
- 40.1.2 New Features
- 40.2 Further Options
- The Authors
- Index