PHP Notes for Professionals book

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

What people are saying about Notes for Professionals books Thank you very much for this! Very useful Good stuff thanks This is really cool! Thanks a lot! Wow. This is awesome. Thank you! Binge downloaded plenty from your site - thanx a million!! Are you a novice, a little above novice, a pro or you want to start coding, then you need to check out these materials. The PHP Notes for Professionals book is compiled from Stack Overflow Documentation, the content is written by the beautiful people at Stack Overflow. Text content is released under Creative Commons BY-SA. See credits at the end of this book whom contributed to the various chapters. Images may be copyright of their respective owners unless otherwise specified Book created for educational purposes and is not affiliated with PHP group(s), company(s) nor Stack Overflow. All trademarks belong to their respective company owners 481 pages, published on June 2018

Author(s): GoalKicker Books
Series: Programming Notes for Professionals
Publisher: GoalKicker Books
Year: 2018

Language: English
Pages: 481
Tags: Programming, Notes, PHP, Professionals

Content list
About
Chapter 1: Getting started with PHP
Section 1.1: HTML output from web server
Section 1.2: Hello, World!
Section 1.3: Non-HTML output from web server
Section 1.4: PHP built-in server
Section 1.5: PHP CLI
Section 1.6: Instruction Separation
Section 1.7: PHP Tags
Chapter 2: Variables
Section 2.1: Accessing A Variable Dynamically By Name (Variable variables)
Section 2.2: Data Types
Section 2.3: Global variable best practices
Section 2.4: Default values of uninitialized variables
Section 2.5: Variable Value Truthiness and Identical Operator
Chapter 3: Variable Scope
Section 3.1: Superglobal variables
Section 3.2: Static properties and variables
Section 3.3: User-defined global variables
Chapter 4: Superglobal Variables PHP
Section 4.1: Suberglobals explained
Section 4.2: PHP5 SuperGlobals
Chapter 5: Outputting the Value of a Variable
Section 5.1: echo and print
Section 5.2: Outputting a structured view of arrays and objects
Section 5.3: String concatenation with echo
Section 5.4: printf vs sprintf
Section 5.5: Outputting large integers
Section 5.6: Output a Multidimensional Array with index and value and print into the table
Chapter 6: Constants
Section 6.1: Defining constants
Section 6.2: Class Constants
Section 6.3: Checking if constant is defined
Section 6.4: Using constants
Section 6.5: Constant arrays
Chapter 7: Magic Constants
Section 7.1: Dierence between __FUNCTION__ and __METHOD__
Section 7.2: Dierence between __CLASS__, get_class() and get_called_class()
Section 7.3: File & Directory Constants
Chapter 8: Comments
Section 8.1: Single Line Comments
Section 8.2: Multi Line Comments
Chapter 9: Types
Section 9.1: Type Comparison
Section 9.2: Boolean
Section 9.3: Float
Section 9.4: Strings
Section 9.5: Callable
Section 9.6: Resources
Section 9.7: Type Casting
Section 9.8: Type Juggling
Section 9.9: Null
Section 9.10: Integers
Chapter 10: Operators
Section 10.1: Null Coalescing Operator (??)
Section 10.2: Spaceship Operator (<=>)
Section 10.3: Execution Operator (``)
Section 10.4: Incrementing (++) and Decrementing Operators (--)
Section 10.5: Ternary Operator (?:)
Section 10.6: Logical Operators (&&/AND and ||/OR)
Section 10.7: String Operators (. and .=)
Section 10.8: Object and Class Operators
Section 10.9: Combined Assignment (+= etc)
Section 10.10: Altering operator precedence (with parentheses)
Section 10.11: Basic Assignment (=)
Section 10.12: Association
Section 10.13: Comparison Operators
Section 10.14: Bitwise Operators
Section 10.15: instanceof (type operator)
Chapter 11: References
Section 11.1: Assign by Reference
Section 11.2: Return by Reference
Section 11.3: Pass by Reference
Chapter 12: Arrays
Section 12.1: Initializing an Array
Section 12.2: Check if key exists
Section 12.3: Validating the array type
Section 12.4: Creating an array of variables
Section 12.5: Checking if a value exists in array
Section 12.6: ArrayAccess and Iterator Interfaces
Chapter 13: Array iteration
Section 13.1: Iterating multiple arrays together
Section 13.2: Using an incremental index
Section 13.3: Using internal array pointers
Section 13.4: Using foreach
Section 13.5: Using ArrayObject Iterator
Chapter 14: Executing Upon an Array
Section 14.1: Applying a function to each element of an array
Section 14.2: Split array into chunks
Section 14.3: Imploding an array into string
Section 14.4: "Destructuring" arrays using list()
Section 14.5: array_reduce
Section 14.6: Push a Value on an Array
Chapter 15: Manipulating an Array
Section 15.1: Filtering an array
Section 15.2: Removing elements from an array
Section 15.3: Sorting an Array
Section 15.4: Whitelist only some array keys
Section 15.5: Adding element to start of array
Section 15.6: Exchange values with keys
Section 15.7: Merge two arrays into one array
Chapter 16: Processing Multiple Arrays Together
Section 16.1: Array intersection
Section 16.2: Merge or concatenate arrays
Section 16.3: Changing a multidimensional array to associative array
Section 16.4: Combining two arrays (keys from one, values from another)
Chapter 17: Datetime Class
Section 17.1: Create Immutable version of DateTime from Mutable prior PHP 5.6
Section 17.2: Add or Subtract Date Intervals
Section 17.3: getTimestamp
Section 17.4: setDate
Section 17.5: Create DateTime from custom format
Section 17.6: Printing DateTimes
Chapter 18: Working with Dates and Time
Section 18.1: Getting the dierence between two dates / times
Section 18.2: Convert a date into another format
Section 18.3: Parse English date descriptions into a Date format
Section 18.4: Using Predefined Constants for Date Format
Chapter 19: Control Structures
Section 19.1: if else
Section 19.2: Alternative syntax for control structures
Section 19.3: while
Section 19.4: do-while
Section 19.5: goto
Section 19.6: declare
Section 19.7: include & require
Section 19.8: return
Section 19.9: for
Section 19.10: foreach
Section 19.11: if elseif else
Section 19.12: if
Section 19.13: switch
Chapter 20: Loops
Section 20.1: continue
Section 20.2: break
Section 20.3: foreach
Section 20.4: do...while
Section 20.5: for
Section 20.6: while
Chapter 21: Functions
Section 21.1: Variable-length argument lists
Section 21.2: Optional Parameters
Section 21.3: Passing Arguments by Reference
Section 21.4: Basic Function Usage
Section 21.5: Function Scope
Chapter 22: Functional Programming
Section 22.1: Closures
Section 22.2: Assignment to variables
Section 22.3: Objects as a function
Section 22.4: Using outside variables
Section 22.5: Anonymous function
Section 22.6: Pure functions
Section 22.7: Common functional methods in PHP
Section 22.8: Using built-in functions as callbacks
Section 22.9: Scope
Section 22.10: Passing a callback function as a parameter
Chapter 23: Alternative Syntax for Control Structures
Section 23.1: Alternative if/else statement
Section 23.2: Alternative for statement
Section 23.3: Alternative while statement
Section 23.4: Alternative foreach statement
Section 23.5: Alternative switch statement
Chapter 24: String formatting
Section 24.1: String interpolation
Section 24.2: Extracting/replacing substrings
Chapter 25: String Parsing
Section 25.1: Splitting a string by separators
Section 25.2: Substring
Section 25.3: Searching a substring with strpos
Section 25.4: Parsing string using regular expressions
Chapter 26: Classes and Objects
Section 26.1: Class Constants
Section 26.2: Abstract Classes
Section 26.3: Late static binding
Section 26.4: Namespacing and Autoloading
Section 26.5: Method and Property Visibility
Section 26.6: Interfaces
Section 26.7: Final Keyword
Section 26.8: Autoloading
Section 26.9: Calling a parent constructor when instantiating a child
Section 26.10: Dynamic Binding
Section 26.11: $this, self and static plus the singleton
Section 26.12: Defining a Basic Class
Section 26.13: Anonymous Classes
Chapter 27: Namespaces
Section 27.1: Declaring namespaces
Section 27.2: Referencing a class or function in a namespace
Section 27.3: Declaring sub-namespaces
Section 27.4: What are Namespaces?
Chapter 28: Sessions
Section 28.1: session_start() Options
Section 28.2: Session Locking
Section 28.3: Manipulating session data
Section 28.4: Destroy an entire session
Section 28.5: Safe Session Start With no Errors
Section 28.6: Session name
Chapter 29: Cookies
Section 29.1: Modifying a Cookie
Section 29.2: Setting a Cookie
Section 29.3: Checking if a Cookie is Set
Section 29.4: Removing a Cookie
Section 29.5: Retrieving a Cookie
Chapter 30: Output Buering
Section 30.1: Basic usage getting content between buers and clearing
Section 30.2: Processing the buer via a callback
Section 30.3: Nested output buers
Section 30.4: Running output buer before any content
Section 30.5: Stream output to client
Section 30.6: Using Output buer to store contents in a file, useful for reports, invoices etc
Section 30.7: Typical usage and reasons for using ob_start
Section 30.8: Capturing the output buer to re-use later
Chapter 31: JSON
Section 31.1: Decoding a JSON string
Section 31.2: Encoding a JSON string
Section 31.3: Debugging JSON errors
Section 31.4: Using JsonSerializable in an Object
Section 31.5: Header json and the returned response
Chapter 32: SOAP Client
Section 32.1: WSDL Mode
Section 32.2: Non-WSDL Mode
Section 32.3: Classmaps
Section 32.4: Tracing SOAP request and response
Chapter 33: Using cURL in PHP
Section 33.1: Basic Usage (GET Requests)
Section 33.2: POST Requests
Section 33.3: Using Cookies
Section 33.4: Using multi_curl to make multiple POST requests
Section 33.5: Sending multi-dimensional data and multiple files with CurlFile in one request
Section 33.6: Creating and sending a request with a custom method
Section 33.7: Get and Set custom http headers in php
Chapter 34: Reflection
Section 34.1: Feature detection of classes or objects
Section 34.2: Testing private/protected methods
Section 34.3: Accessing private and protected member variables
Chapter 35: Dependency Injection
Section 35.1: Constructor Injection
Section 35.2: Setter Injection
Section 35.3: Container Injection
Chapter 36: XML
Section 36.1: Create a XML using DomDocument
Section 36.2: Read a XML document with DOMDocument
Section 36.3: Leveraging XML with PHP's SimpleXML Library
Section 36.4: Create an XML file using XMLWriter
Section 36.5: Read a XML document with SimpleXML
Chapter 37: SimpleXML
Section 37.1: Loading XML data into simplexml
Chapter 38: Parsing HTML
Section 38.1: Parsing HTML from a string
Section 38.2: Using XPath
Section 38.3: SimpleXML
Chapter 39: Regular Expressions (regexp/PCRE)
Section 39.1: Global RegExp match
Section 39.2: String matching with regular expressions
Section 39.3: Split string into array by a regular expression
Section 39.4: String replacing with regular expression
Section 39.5: String replace with callback
Chapter 40: Traits
Section 40.1: What is a Trait?
Section 40.2: Traits to facilitate horizontal code reuse
Section 40.3: Conflict Resolution
Section 40.4: Implementing a Singleton using Traits
Section 40.5: Traits to keep classes clean
Section 40.6: Multiple Traits Usage
Section 40.7: Changing Method Visibility
Chapter 41: Composer Dependency Manager
Section 41.1: What is Composer?
Section 41.2: Autoloading with Composer
Section 41.3: Dierence between 'composer install' and 'composer update'
Section 41.4: Composer Available Commands
Section 41.5: Benefits of Using Composer
Section 41.6: Installation
Chapter 42: Magic Methods
Section 42.1: __call() and __callStatic()
Section 42.2: __get(), __set(), __isset() and __unset()
Section 42.3: __construct() and __destruct()
Section 42.4: __toString()
Section 42.5: __clone()
Section 42.6: __invoke()
Section 42.7: __sleep() and __wakeup()
Section 42.8: __debugInfo()
Chapter 43: File handling
Section 43.1: Convenience functions
Section 43.2: Deleting files and directories
Section 43.3: Getting file information
Section 43.4: Stream-based file IO
Section 43.5: Moving and Copying files and directories
Section 43.6: Minimize memory usage when dealing with large files
Chapter 44: Streams
Section 44.1: Registering a stream wrapper
Chapter 45: Type hinting
Section 45.1: Type hinting classes and interfaces
Section 45.2: Type hinting scalar types, arrays and callables
Section 45.3: Nullable type hints
Section 45.4: Type hinting generic objects
Section 45.5: Type Hinting No Return(Void)
Chapter 46: Filters & Filter Functions
Section 46.1: Validating Boolean Values
Section 46.2: Validating A Number Is A Float
Section 46.3: Validate A MAC Address
Section 46.4: Sanitze Email Addresses
Section 46.5: Sanitize Integers
Section 46.6: Sanitize URLs
Section 46.7: Validate Email Address
Section 46.8: Validating A Value Is An Integer
Section 46.9: Validating An Integer Falls In A Range
Section 46.10: Validate a URL
Section 46.11: Sanitize Floats
Section 46.12: Validate IP Addresses
Section 46.13: Sanitize filters
Chapter 47: Generators
Section 47.1: The Yield Keyword
Section 47.2: Reading a large file with a generator
Section 47.3: Why use a generator?
Section 47.4: Using the send()-function to pass values to a generator
Chapter 48: UTF-8
Section 48.1: Input
Section 48.2: Output
Section 48.3: Data Storage and Access
Chapter 49: Unicode Support in PHP
Section 49.1: Converting Unicode characters to “\uxxxx” format using PHP
Section 49.2: Converting Unicode characters to their numeric value and/or HTML entities using PHP
Section 49.3: Intl extention for Unicode support
Chapter 50: URLs
Section 50.1: Parsing a URL
Section 50.2: Build an URL-encoded query string from an array
Section 50.3: Redirecting to another URL
Chapter 51: How to break down an URL
Section 51.1: Using parse_url()
Section 51.2: Using explode()
Section 51.3: Using basename()
Chapter 52: Object Serialization
Section 52.1: Serialize / Unserialize
Section 52.2: The Serializable interface
Chapter 53: Serialization
Section 53.1: Serialization of dierent types
Section 53.2: Security Issues with unserialize
Chapter 54: Closure
Section 54.1: Basic usage of a closure
Section 54.2: Using external variables
Section 54.3: Basic closure binding
Section 54.4: Closure binding and scope
Section 54.5: Binding a closure for one call
Section 54.6: Use closures to implement observer pattern
Chapter 55: Reading Request Data
Section 55.1: Reading raw POST data
Section 55.2: Reading POST data
Section 55.3: Reading GET data
Section 55.4: Handling file upload errors
Section 55.5: Passing arrays by POST
Section 55.6: Uploading files with HTTP PUT
Chapter 56: Type juggling and Non-Strict Comparison Issues
Section 56.1: What is Type Juggling?
Section 56.2: Reading from a file
Section 56.3: Switch surprises
Section 56.4: Strict typing
Chapter 57: Sockets
Section 57.1: TCP client socket
Section 57.2: TCP server socket
Section 57.3: UDP server socket
Section 57.4: Handling socket errors
Chapter 58: PDO
Section 58.1: Preventing SQL injection with Parameterized Queries
Section 58.2: Basic PDO Connection and Retrieval
Section 58.3: Database Transactions with PDO
Section 58.4: PDO: connecting to MySQL/MariaDB server
Section 58.5: PDO: Get number of aected rows by a query
Section 58.6: PDO::lastInsertId()
Chapter 59: PHP MySQLi
Section 59.1: Close connection
Section 59.2: MySQLi connect
Section 59.3: Loop through MySQLi results
Section 59.4: Prepared statements in MySQLi
Section 59.5: Escaping Strings
Section 59.6: Debugging SQL in MySQLi
Section 59.7: MySQLi query
Section 59.8: How to get data from a prepared statement
Section 59.9: MySQLi Insert ID
Chapter 60: SQLite3
Section 60.1: SQLite3 Quickstart Tutorial
Section 60.2: Querying a database
Section 60.3: Retrieving only one result
Chapter 61: Using MongoDB
Section 61.1: Connect to MongoDB
Section 61.2: Get multiple documents - find()
Section 61.3: Get one document - findOne()
Section 61.4: Insert document
Section 61.5: Update a document
Section 61.6: Delete a document
Chapter 62: mongo-php
Section 62.1: Everything in between MongoDB and Php
Chapter 63: Using Redis with PHP
Section 63.1: Connecting to a Redis instance
Section 63.2: Installing PHP Redis on Ubuntu
Section 63.3: Executing Redis commands in PHP
Chapter 64: Sending Email
Section 64.1: Sending Email - The basics, more details, and a full example
Section 64.2: Sending HTML Email Using mail()
Section 64.3: Sending Email With An Attachment Using mail()
Section 64.4: Sending Plain Text Email Using PHPMailer
Section 64.5: Sending HTML Email Using PHPMailer
Section 64.6: Sending Email With An Attachment Using PHPMailer
Section 64.7: Sending Plain Text Email Using Sendgrid
Section 64.8: Sending Email With An Attachment Using Sendgrid
Chapter 65: Using SQLSRV
Section 65.1: Retrieving Error Messages
Section 65.2: Fetching Query Results
Section 65.3: Creating a Connection
Section 65.4: Making a Simple Query
Section 65.5: Invoking a Stored Procedure
Section 65.6: Making a Parameterised Query
Chapter 66: Command Line Interface (CLI)
Section 66.1: Handling Program Options
Section 66.2: Argument Handling
Section 66.3: Input and Output Handling
Section 66.4: Return Codes
Section 66.5: Restrict script execution to command line
Section 66.6: Behavioural dierences on the command line
Section 66.7: Running your script
Section 66.8: Edge Cases of getopt()
Section 66.9: Running built-in web server
Chapter 67: Localization
Section 67.1: Localizing strings with gettext()
Chapter 68: Headers Manipulation
Section 68.1: Basic Setting of a Header
Chapter 69: Coding Conventions
Section 69.1: PHP Tags
Chapter 70: Asynchronous programming
Section 70.1: Advantages of Generators
Section 70.2: Using Icicle event loop
Section 70.3: Spawning non-blocking processes with proc_open()
Section 70.4: Reading serial port with Event and DIO
Section 70.5: HTTP Client Based on Event Extension
Section 70.6: HTTP Client Based on Ev Extension
Section 70.7: Using Amp event loop
Chapter 71: How to Detect Client IP Address
Section 71.1: Proper use of HTTP_X_FORWARDED_FOR
Chapter 72: Create PDF files in PHP
Section 72.1: Getting Started with PDFlib
Chapter 73: YAML in PHP
Section 73.1: Installing YAML extension
Section 73.2: Using YAML to store application configuration
Chapter 74: Image Processing with GD
Section 74.1: Image output
Section 74.2: Creating an image
Section 74.3: Image Cropping and Resizing
Chapter 75: Imagick
Section 75.1: First Steps
Section 75.2: Convert Image into base64 String
Chapter 76: SOAP Server
Section 76.1: Basic SOAP Server
Chapter 77: Machine learning
Section 77.1: Classification using PHP-ML
Section 77.2: Regression
Section 77.3: Clustering
Chapter 78: Cache
Section 78.1: Caching using memcache
Section 78.2: Cache Using APC Cache
Chapter 79: Autoloading Primer
Section 79.1: Autoloading as part of a framework solution
Section 79.2: Inline class definition, no loading required
Section 79.3: Manual class loading with require
Section 79.4: Autoloading replaces manual class definition loading
Section 79.5: Autoloading with Composer
Chapter 80: SPL data structures
Section 80.1: SplFixedArray
Chapter 81: IMAP
Section 81.1: Connecting to a mailbox
Section 81.2: Install IMAP extension
Section 81.3: List all folders in the mailbox
Section 81.4: Finding messages in the mailbox
Chapter 82: HTTP Authentication
Section 82.1: Simple authenticate
Chapter 83: WebSockets
Section 83.1: Simple TCP/IP server
Chapter 84: BC Math (Binary Calculator)
Section 84.1: Using bcmath to read/write a binary long on 32-bit system
Section 84.2: Comparison between BCMath and float arithmetic operations
Chapter 85: Docker deployment
Section 85.1: Get docker image for php
Section 85.2: Writing dockerfile
Section 85.3: Building image
Section 85.4: Starting application container
Chapter 86: APCu
Section 86.1: Iterating over Entries
Section 86.2: Simple storage and retrieval
Section 86.3: Store information
Chapter 87: PHP Built in server
Section 87.1: Running the built in server
Section 87.2: built in server with specific directory and router script
Chapter 88: PSR
Section 88.1: PSR-4: Autoloader
Section 88.2: PSR-1: Basic Coding Standard
Chapter 89: PHPDoc
Section 89.1: Describing a variable
Section 89.2: Adding metadata to functions
Section 89.3: Describing parameters
Section 89.4: Collections
Section 89.5: Adding metadata to files
Section 89.6: Inheriting metadata from parent structures
Chapter 90: Design Patterns
Section 90.1: Method Chaining in PHP
Chapter 91: Compile PHP Extensions
Section 91.1: Compiling on Linux
Chapter 92: Common Errors
Section 92.1: Call fetch_assoc on boolean
Section 92.2: Unexpected $end
Chapter 93: Compilation of Errors and Warnings
Section 93.1: Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM
Section 93.2: Notice: Undefined index
Section 93.3: Warning: Cannot modify header information - headers already sent
Chapter 94: Exception Handling and Error Reporting
Section 94.1: Setting error reporting and where to display them
Section 94.2: Logging fatal errors
Chapter 95: Debugging
Section 95.1: Dumping variables
Section 95.2: Displaying errors
Section 95.3: phpinfo()
Section 95.4: Xdebug
Section 95.5: Error Reporting (use them both)
Section 95.6: phpversion()
Chapter 96: Unit Testing
Section 96.1: Testing class rules
Section 96.2: PHPUnit Data Providers
Section 96.3: Test exceptions
Chapter 97: Performance
Section 97.1: Profiling with Xdebug
Section 97.2: Memory Usage
Section 97.3: Profiling with XHProf
Chapter 98: Multiprocessing
Section 98.1: Multiprocessing using built-in fork functions
Section 98.2: Creating child process using fork
Section 98.3: Inter-Process Communication
Chapter 99: Multi Threading Extension
Section 99.1: Getting Started
Section 99.2: Using Pools and Workers
Chapter 100: Secure Remeber Me
Section 100.1: “Keep Me Logged In” - the best approach
Chapter 101: Security
Section 101.1: PHP Version Leakage
Section 101.2: Cross-Site Scripting (XSS)
Section 101.3: Cross-Site Request Forgery
Section 101.4: Command Line Injection
Section 101.5: Stripping Tags
Section 101.6: File Inclusion
Section 101.7: Error Reporting
Section 101.8: Uploading files
Chapter 102: Cryptography
Section 102.1: Symmetric Encryption and Decryption of large Files with OpenSSL
Section 102.2: Symmetric Cipher
Chapter 103: Password Hashing Functions
Section 103.1: Creating a password hash
Section 103.2: Determine if an existing password hash can be upgraded to a stronger algorithm
Section 103.3: Verifying a password against a hash
Chapter 104: Contributing to the PHP Manual
Section 104.1: Improve the ocial documentation
Section 104.2: Tips for contributing to the manual
Chapter 105: Contributing to the PHP Core
Section 105.1: Setting up a basic development environment
Appendix A: Installing a PHP environment on Windows
Section A.1: Download, Install and use WAMP
Section A.2: Install PHP and use it with IIS
Section A.3: Download and Install XAMPP
Appendix B: Installing on Linux/Unix Environments
Section B.1: Command Line Install Using APT for PHP 7
Section B.2: Installing in Enterprise Linux distributions (CentOS, Scientific Linux, etc)
Credits
You may also like