PHP - Learn Programming Languages With Books And Examples

Transcription

PHP#php

Table of ContentsAbout1Chapter 1: Getting started with PHP2Remarks2Versions3PHP 7.x3PHP 5.x3PHP 4.x3Legacy Versions4Examples4HTML output from web server4Non-HTML output from web server5Hello, World!6Instruction Separation6PHP CLI7Triggering7Output8Input9PHP built-in server9Example usage9Configuration9LogsPHP Tags1010Standard Tags10Echo Tags10Short Tags10ASP Tags11Chapter 2: Alternative Syntax for Control Structures12Syntax12Remarks12

Examples12Alternative for statement12Alternative while statement12Alternative foreach statement12Alternative switch statement13Alternative if/else statement13Chapter 3: APCu15Introduction15Examples15Simple storage and retrieval15Store information15Iterating over Entries15Chapter 4: Array iteration17Syntax17Remarks17Comparison of methods to iterate an arrayExamples1717Iterating multiple arrays together17Using an incremental index18Using internal array pointers19Using each19Using next20Using foreach20Direct loop20Loop with keys20Loop by reference20ConcurrencyUsing ArrayObject IteratorChapter 5: Arrays212223Introduction23Syntax23

Parameters23Remarks23See alsoExamples2323Initializing an Array23Check if key exists26Checking if a value exists in array27Validating the array type28ArrayAccess and Iterator Interfaces28Creating an array of variables32Chapter 6: Asynchronous programmingExamples3333Advantages of Generators33Using Icicle event loop33Using Amp event loop34Spawning non-blocking processes with proc open()34Reading serial port with Event and DIO36TestingHTTP Client Based on Event P Client Based on Ev Extensionhttp-client.phpTestingChapter 7: Autoloading Primer41414547Syntax47Remarks47Examples47Inline class definition, no loading required47Manual class loading with require47Autoloading replaces manual class definition loading48

Autoloading as part of a framework solution48Autoloading with Composer49Chapter 8: BC Math (Binary arks53Examples53Comparison between BCMath and float arithmetic operations53bcadd vs float float53bcsub vs float-float53bcmul vs int*int53bcmul vs float*float53bcdiv vs float/float54Using bcmath to read/write a binary long on 32-bit systemChapter 9: Cache5456Remarks56Installation56Examples56Caching using memcache56Store data57Get data57Delete data57Small scenario for caching57Cache Using APC Cache58Chapter 10: Classes and Objects59Introduction59Syntax59Remarks59Classes and Interface componentsExamples5960

61Examples61Class Constants63define vs class constants65Using ::class to retrieve class's name66Late static binding66Abstract Classes67Important Note69Namespacing and Autoloading69Dynamic Binding71Method and Property Visibility72Public72Protected72Private73Calling a parent constructor when instantiating a child74Final Keyword75 this, self and static plus the singleton76The singleton78Autoloading79Anonymous Classes81Defining a Basic Class82Constructor82Extending Another Class82Chapter 11: Closure84Examples84Basic usage of a closure84Using external variables85Basic closure binding85

Closure binding and scope86Binding a closure for one call87Use closures to implement observer pattern88Chapter 12: Coding ConventionsExamplesPHP TagsChapter 13: Command Line Interface (CLI)Examples9090909191Argument Handling91Input and Output Handling92Return Codes93Handling Program Options93Restrict script execution to command line94Running your script95Behavioural differences on the command line95Running built-in web server96Edge Cases of getopt()96Chapter 14: Comments98Remarks98Examples98Single Line Comments98Multi Line Comments98Chapter 15: Common ErrorsExamples9999Unexpected end99Call fetch assoc on boolean99Chapter 16: Compilation of Errors and WarningsExamples101101Notice: Undefined index101Warning: Cannot modify header information - headers already sent101Parse error: syntax error, unexpected T PAAMAYIM NEKUDOTAYIM101Chapter 17: Compile PHP Extensions103

ExamplesCompiling on Linux103103Steps to compile103Loading the Extension in PHP103Chapter 18: Composer Dependency arks105Helpful Links105Few Suggestions105Examples106What is Composer?106Autoloading with Composer106Benefits of Using Composer107Difference between 'composer install' and 'composer update'108composer update108composer install108When to install and when to update109Composer Available pter 19: Constants112Syntax112Remarks112Examples112Checking if constant is defined112Simple check112Getting all defined constants113Defining constants113

Define constant using explicit values114Define constant using another constant114Reserved constants114Conditional defines114const vs define115Class Constants115Constant arrays116Class constant example116Plain constant example116Using constantsChapter 20: Contributing to the PHP Core116118Remarks118Contributing with Bug Fixes118Contributing with Feature ting up a basic development environment119Chapter 21: Contributing to the PHP ve the official documentation121Tips for contributing to the manual121Chapter 22: Control StructuresExamples123123Alternative syntax for control structures123while123do-while123goto124declare124

if else124include & ch127if elseif else127if128switch128Chapter 23: arks130Examples131Setting a Cookie131Retrieving a Cookie131Modifying a Cookie132Checking if a Cookie is Set132Removing a Cookie132Chapter 24: Create PDF files in PHPExamples134134Getting Started with PDFlib134Chapter 25: Cryptography135Remarks135Examples135Symmetric Cipher135Encryption135Decryption135Base64 Encode & Decode136

Symmetric Encryption and Decryption of large Files with OpenSSL136Encrypt Files136Decrypt Files137How to use138Chapter 26: Datetime ClassExamples139139getTimestamp139setDate139Add or Subtract Date Intervals139Create DateTime from custom format140Printing riented141Procedural Equivalent141Create Immutable version of DateTime from Mutable prior PHP 5.6Chapter 27: DebuggingExamples141142142Dumping variables142Displaying le145Error Reporting (use them both)145Chapter 28: Dependency Injection146

Introduction146Examples146Constructor Injection146Setter Injection147Container Injection148Chapter 29: Design Patterns150Introduction150Examples150Method Chaining in PHP150When to use it151Additional Notes151Command Query Separation151Getters151Law of Demeter and impact on testing151Chapter 30: Docker et docker image for php153Writing dockerfile153Ignoring files154Building image154Starting application container154Checking container154Application logs154Chapter 31: Exception Handling and Error ReportingExamples155155Setting error reporting and where to display them155Exception and Error handling155try/catch155Catching different Exception types156

finally156throwable157Logging fatal errorsChapter 32: Executing Upon an ArrayExamples157159159Applying a function to each element of an array159Split array into chunks160Imploding an array into string161array reduce161"Destructuring" arrays using list()163Push a Value on an Array163Chapter 33: File e syntaxExamplesDeleting files and directories165166166Deleting files166Deleting directories, with recursive deletion166Convenience functions167Raw direct IO167CSV IO167Reading a file to stdout directly168Or from a file pointerReading a file into an arrayGetting file information168168169Check if a path is a directory or a file169Checking file type169Checking readability and writability170Checking file access/modify time170

Get path parts with fileinfo170Minimize memory usage when dealing with large files171Stream-based file IO172Opening a stream172Reading173Reading lines173Reading everything remaining173Adjusting file pointer position173Writing174Moving and Copying files and directories174Copying files174Copying directories, with recursion174Renaming/Moving175Chapter 34: Filters & Filter xamples176Validate Email Address176Validating A Value Is An Integer177Validating An Integer Falls In A Range177Validate a URL178Sanitize filters180Validating Boolean Values180Validating A Number Is A Float181Validate A MAC Address182Sanitze Email Addresses182Sanitize Integers182Sanitize URLs183Sanitize Floats184Validate IP Addresses185

Chapter 35: Functional Programming188Introduction188Examples188Assignment to variables188Using outside variables188Passing a callback function as a parameter189Procedural style:189Object Oriented style:189Object Oriented style using a static method:189Using built-in functions as callbacks190Anonymous function190Scope191Closures191Pure functions193Objects as a function193Common functional methods in PHP194Mapping194Reducing (or folding)194Filtering194Chapter 36: Functions195Syntax195Examples195Basic Function Usage195Optional Parameters195Passing Arguments by Reference196Variable-length argument lists197Function Scope198Chapter 37: GeneratorsExamples200200Why use a generator?200Re-writing randomNumbers() using a generator200Reading a large file with a generator201

The Yield Keyword201Yielding Values202Yielding Values with Keys202Using the send()-function to pass values to a generatorChapter 38: Headers ManipulationExamplesBasic Setting of a HeaderChapter 39: How to break down an URL202204204204206Introduction206Examples206Using parse url()206Using explode()207Using basename()208Chapter 40: How to Detect Client IP AddressExamplesProper use of HTTP X FORWARDED FORChapter 41: HTTP 11Simple authenticateChapter 42: Image Processing with GD211212Remarks212Examples212Creating an imageConverting an image212212Image output212Saving to a file213Output as an HTTP response213Writing into a variable213Using OB (Output Buffering)213Using stream wrappers214

Example usageImage Cropping and ResizingChapter 43: ImagickExamples214215218218First Steps218Convert Image into base64 String218Chapter 44: IMAPExamples220220Install IMAP extension220Connecting to a mailbox220List all folders in the mailbox222Finding messages in the mailbox222Chapter 45: Installing a PHP environment on Windows225Remarks225Examples225Download and Install XAMPP225What is XAMPP?225Where should I download it from?225How to install and where should I place my PHP/html files?225Install with the provided installer225Install from the ZIP226Post-Install226File handling226Download, Install and use WAMP227Install PHP and use it with IIS228Chapter 46: Installing on Linux/Unix EnvironmentsExamples230230Command Line Install Using APT for PHP 7230Installing in Enterprise Linux distributions (CentOS, Scientific Linux, etc)230Chapter 47: JSONIntroduction232232

g a JSON string233Encoding a JSON string236Arguments236JSON FORCE OBJECT236JSON HEX TAG, JSON HEX AMP, JSON HEX APOS, JSON HEX QUOT237JSON NUMERIC CHECK237JSON PRETTY PRINT238JSON UNESCAPED SLASHES238JSON UNESCAPED UNICODE238JSON PARTIAL OUTPUT ON ERROR238JSON PRESERVE ZERO FRACTION239JSON UNESCAPED LINE TERMINATORS239Debugging JSON errors239json last error msg240json last error240Using JsonSerializable in an Object241properties values example.242Using Private and Protected Properties with json encode()242Output:243Header json and the returned responseChapter 48: Localization243244Syntax244Examples244Localizing strings with gettext()Chapter 49: Loops244246Introduction246Syntax246

ile249continue249while251Chapter 50: Machine learning252Remarks252Examples252Classification using PHP-ML252SVC (Support Vector Classification)252k-Nearest Neighbors253NaiveBayes Classifier253Practical case254Regression254Support Vector Regression254LeastSquares Linear Regression255Practical case255Clustering256k-Means256DBSCAN256Practical CaseChapter 51: Magic Constants257258Remarks258Examples258Difference between FUNCTION and METHOD258Difference between CLASS , get class() and get called class()259File & Directory Constants259Current file259

Current directory260Separators260Chapter 52: Magic Methods261Examplesget(), set(), isset() and unset()empty() function and magic methods261261262construct() and destruct()262toString()263invoke()263call() and callStatic()264Example:265sleep() and wakeup()265debugInfo()266clone()267Chapter 53: Manipulating an ArrayExamplesRemoving elements from an arrayRemoving terminal elementsFiltering an array268268268268269Filtering non-empty values269Filtering by callback269Filtering by index270Indexes in filtered array270Adding element to start of array271Whitelist only some array keys272Sorting an ort()274

6usort()276uasort()276uksort()277Exchange values with keys278Merge two arrays into one array278Chapter 54: mongo-php279Syntax279Examples279Everything in between MongoDB and Php279Chapter 55: Multi Threading Extension282Remarks282Examples282Getting Started282Using Pools and Workers283Chapter 56: Multiprocessing285Examples285Multiprocessing using built-in fork functions285Creating child process using fork285Inter-Process Communication286Chapter 57: Namespaces287Remarks287Examples287Declaring namespaces287Referencing a class or function in a namespace288What are Namespaces?289Declaring sub-namespaces289Chapter 58: Object Serialization291

Syntax291Remarks291Examples291Serialize / Unserialize291The Serializable interface291Chapter 59: ring Operators (. and . )294Basic Assignment ( )294Combined Assignment ( etc)295Altering operator precedence (with parentheses)296Association296Left association296Right association296Comparison Operators297Equality297Comparison of objects297Other commonly used operators297Spaceship Operator ( )298Null Coalescing Operator (?)299instanceof (type operator)300Caveats301Older versions of PHP (before 5.0)302Ternary Operator (?:)302Incrementing ( ) and Decrementing Operators (--)303Execution Operator ( )303Logical Operators (&&/AND and /OR)303Bitwise Operators304Prefix bitwise operators304

Bitmask-bitmask operators304Example uses of bitmasks304Bit-shifting operatorsExample uses of bit shifting:Object and Class OperatorsChapter 60: Output Buffering306306306309Parameters309Examples309Basic usage getting content between buffers and clearing309Nested output buffers310Capturing the output buffer to re-use later311Running output buffer before any content312Using Output buffer to store contents in a file, useful for reports, invoices etc312Processing the buffer via a callback313Stream output to client313Typical usage and reasons for using ob start314Chapter 61: Outputting the Value of a o and print315Shorthand notation for echo316Priority of print316Differences between echo and print317Outputting a structured view of arrays and objects317print r() - Outputting Arrays and Objects for debugging317var dump() - Output human-readable debugging information about content of the argument(s)318var export() - Output valid PHP Code319printf vs sprintf319String concatenation with echo320String concatenation vs passing multiple arguments to echo320

Outputting large integers321Output a Multidimensional Array with index and value and print into the table321Chapter 62: Parsing HTMLExamples323323Parsing HTML from a string323Using XPath323SimpleXML323Presentation323Parsing XML using procedural approach324Parsing XML using OOP approach324Accessing Children and Attributes324When you know their names:324When you don't know their names (or you don't want to know them):325Chapter 63: Password Hashing rithm Selection326Secure algorithms326Insecure algorithms326Examples327Determine if an existing password hash can be upgraded to a stronger algorithm327Creating a password hash328Salt for password hashVerifying a password against a hashChapter 64: ples331Basic PDO Connection and Retrieval331

Preventing SQL injection with Parameterized Queries332PDO: connecting to MySQL/MariaDB server333Standard (TCP/IP) connection333Socket connection334Database Transactions with PDO334PDO: Get number of affected rows by a query337PDO::lastInsertId()338Chapter 65: PerformanceExamples339339Profiling with XHProf339Memory Usage339Profiling with Xdebug340Chapter 66: PHP Built in mples343Running the built in server343built in server with specific directory and router script344Chapter 67: PHP natives345Examples345MySQLi connect345MySQLi query346Loop through MySQLi results347Close connection348Prepared statements in MySQLi348Escaping Strings349

MySQLi Insert ID350Debugging SQL in MySQLi351How to get data from a prepared statement352Prepared statements352Binding of results352What if I cannot install mysqlnd?353Chapter 68: php mysqli affected rows returns 0 when it should return a positive integer355Introduction355Examples355PHP's stmt- affected rows intermittently returning 0 when it should return a positive intChapter 69: PHPDoc355356Syntax356Remarks356Examples357Adding metadata to functions357Adding metadata to files357Inheriting metadata from parent structures358Describing a variable358Describing parameters359Collections359Generics Syntax359Examples360Chapter 70: Processing Multiple Arrays Together362Examples362Merge or concatenate arrays362Array intersection362Combining two arrays (keys from one, values from another)363Changing a multidimensional array to associative array363Chapter 71: PSR365Introduction365Examples365

PSR-4: Autoloader365PSR-1: Basic Coding Standard366PSR-8: Huggable Interface366Chapter 72: Reading Request Data368Remarks368Choosing between GET and POST368Request Data Vulnerabilities368Examples368Handling file upload errors368Reading POST data369Reading GET data369Reading raw POST data370Uploading files with HTTP PUT370Passing arrays by POST371Chapter 73: Recipes373Introduction373Examples373Create a site visit counterChapter 74: gn by Reference374Return by Reference375NotesPass by Reference376376Arrays376Functions377Chapter 75: Reflection379ExamplesAccessing private and protected member variables379379

Feature detection of classes or objects381Testing private/protected methods382Chapter 76: Regular Expressions amples384String matching with regular expressions384Split string into array by a regular expression385String replacing with regular expression385Global RegExp match386String replace with callback387Chapter 77: Secure Remeber Me389Introduction389Examples389“Keep Me Logged In” - the best approachChapter 78: Error Reporting390A quick solution390Handling errors390Cross-Site Scripting (XSS)391Problem391Solution392Filter Functions392HTML Encoding392URL Encoding392Using specialised external libraries or OWASP AntiSamy lists393File Inclusion393Remote File Inclusion393

Local File Inclusion393Solution to RFI & LFI:393Command Line Injection394Problem394Solution394PHP Version Leakage395Stripping Tags395Basic Example395Allowing Tags396Notice(s)396Cross-Site Request Forgery396Problem396Solution397Sample code397Uploading files398The uploaded data:398Exploiting the file name398Getting the file name and extension safely399Mime-type validation399White listing your uploads400Chapter 79: Sending Email401Parameters401Remarks401Examples402Sending Email - The basics, more details, and a full example402Sending HTML Email Using mail()405Sending Plain Text Email Using PHPMailer405Sending Email With An Attachment Using mail()406Content-Transfer-Encodings407Sending HTML Email Using PHPMailer408Sending Email With An Attachment Using PHPMailer408

Sending Plain Text Email Using Sendgrid409Sending Email With An Attachment Using Sendgrid410Chapter 80: amples412Serialization of different types412Serializing a string412Serializing a double412Serializing a float412Serializing an integer412Serializing a boolean412Serializing null413Serializing an array413Serializing an object413Note that Closures cannot be serialized:414Security Issues with unserialize414Possible Attacks414PHP Object Injection414Chapter 81: ing session dataWarning:417418Destroy an entire session418session start() Options419Session name419Checking if session cookies have been created419Changing session name420

Session Locking420Safe Session Start With no Errors421Chapter 82: SimpleXMLExamplesLoading XML data into simplexml422422422Loading from string422Loading from file422Chapter 83: SOAP 25WSDL Mode425Non-WSDL Mode425Classmaps426Tracing SOAP request and response427Chapter 84: SOAP Server428Syntax428Examples428Basic SOAP Server428Chapter 85: Sockets429ExamplesTCP client socket429429Creating a socket that uses the TCP (Transmission Control Protocol)429Connect the socket to a specified address429Sending data to the server429Receiving data from the server429Closing the socket430TCP server socket430Socket creation430Socket binding430

Set a socket to listening431Handling connection431Closing the server431Handling socket errors431UDP server socket431Creating a UDP server socket432Binding a socket to an address432Sending a packet432Receiving a packet432Closing the server432Chapter 86: SPL data structures433ExamplesSplFixedArray433433Difference from PHP Array433Instantiating the array435Resizing the array435Import to SplFixedArray & Export from SplFixedArray436Chapter 87: SQLite3438Examples438Querying a database438Retrieving only one result438SQLite3 Quickstart Tutorial438Creating/opening a database438Creating a table439Inserting sample data.439Fetching data439Shorthands440Cleaning up440Chapter 88: Streams441Syntax441

Parameters441Remarks441Examples441Registering a stream wrapper442Chapter 89: String formatting444Examples444Extracting/replacing substrings444String interpolation444Chapter 90: String Parsing447Remarks447Examples447Splitting a string by separators447Searching a substring with strpos448Checking if a substring exists448Search starting from an offset448Get all occurrences of a substring449Parsing string using regular expressions449Substring450Chapter 91: Superglobal Variables PHP452Introduction452Examples452PHP5 SuperGlobals452Suberglobals explained455IntroductionWhat's a superglobal?Tell me more, tell me more GLOBALSBecoming global455455456456457 SERVER457 GET459 POST459

FILES460 COOKIE462 SESSION462 REQUEST463 ENV463Chapter 92: TraitsExamples464464Traits to facilitate horizontal code reuse464Conflict Resolution465Multiple Traits Usage466Changing Method Visibility467What is a Trait?467When should I use a Trait?468Traits to keep classes clean468Implementing a Singleton using Traits469Chapter 93: Type hinting472Syntax472Remarks472Examples472Type hinting scalar types, arrays and callables472An Exception: Special Types474Type hinting generic objects474Type hinting classes and interfaces475Class type hint475Interface type hint475Self type hints476Type Hinting No Return(Void)476Nullable type hints477Parameters477Return values477Chapter 94: Type juggling and Non-Strict Comparison Issues478

Examples478What is Type Juggling?478Reading from a file479Switch surprises479Explicit casting480Avoid switch480Strict typing481Chapter 95: Types482Examples482Integers482Strings483Single Quoted483Double ing486Callable487Null487Null vs undefined variable487Type Comparison488Type Casting488Resources489Type Juggling490Chapter 96: Unicode Support in PHPExamplesConverting Unicode characters to “\uxxxx” format using PHP491491491How to use :491Output :491Converting Unicode characters to their numeric value and/or HTML entities using PHP491

How to use :492Output :493Intl extention for Unicode supportChapter 97: Unit Testing493494Syntax494Remarks494Examples494Testing class rules494PHPUnit Data Providers497Array of arrays498Iterators499Generators500Test exceptionsChapter 98: URLsExamples501503503Parsing a URL503Redirecting to another URL503Build an URL-encoded query string from an array504Chapter 99: Using cURL in PHP506Syntax506Parameters506Examples506Basic Usage (GET Requests)506POST Requests507Using multi curl to make multiple POST requests507Creating and sending a request with a custom method509Using Cookies509Sending multi-dimensional data and multiple files with CurlFile in one request510Get and Set custom http headers in php513Chapter 100: Using MongoDBExamplesConnect to MongoDB515515515

Get one document - findOne()515Get multiple documents - find()515Insert document515Update a document516Delete a document516Chapter 101: Using Redis with PHPExamples517517Installing PHP Redis on Ubuntu517Connecting to a Redis instance517Executing Redis commands in PHP517Chapter 102: Using SQLSRV518Remarks518Examples518Creating a Connection518Making a Simple Query519Invoking a Stored Procedure519Making a Parameterised Query519Fetching Query Results520sqlsrv fetch array()520sqlsrv fetch object()520sqlsrv fetch()520Retrieving Error MessagesChapter 103: ata Storage and Access523Chapter 104: Variable Scope525Introduction525Examples525User-defined global variables525

Superglobal variables526Static properties and variables526Chapter 105: Variables528Syntax528Remarks528Type checkingExamplesAccessing A Variable Dynamically By Name (Variable variables)Differences between PHP5 and PHP7528529529530Case 1 : foo['bar']['baz']531Case 2 : foo- bar['baz']531Case 3 : foo- bar['baz']()531Case 4 : Foo:: bar['baz']()531Data 2String533Object533Resource533Global variable best practices533Getting all defined variables535Default values of uninitialized variables536Variable Value Truthiness and Identical Operator536Chapter 106: WebSockets540Introduction540Examples540Simple TCP/IP serverChapter 107: Working with Dates and Time540542

Syntax542Examples542Parse English date descriptions into a Date format542Convert a date into another format542Using Predefined Constants for Date Format544Getting the difference between two dates / times545Chapter 108: XMLExamples547547Create an XML file using XMLWriter547Read a XML document with DOMDocument547Create a XML using DomDocument548Read a XML document with SimpleXML550Leveraging XML with PHP's SimpleXML Library551Chapter 109: YAML in PHPExamples554554Installing YAML extension554Using YAML to store application configuration554Credits556

AboutYou can share this PDF with anyone you feel could benefit from it, downloaded the latest versionfrom: phpIt is an unofficial and free PHP ebook created for educational purposes. All the content is extractedfrom Stack Overflow Documentation, which is written by many hardworking individuals at StackOverflow. It is neither affiliated with Stack Overflow nor official PHP.The content is released under Creative Commons BY-SA, and the list of contributors to eachchapter are provided in the credits section at the end of this book. Images may be copyright oftheir respective owners unless otherwise specified. All trademarks and registered trademarks arethe property of their respective company owners.Use the content presented in this book at your own risk; it is not guaranteed to be correct noraccurate, please send your feedback and corrections to info@zzzprojects.comhttps://riptutorial.com/1

Chapter 1: Getting started with PHPRemarksPHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open sourceprogramming language. It is especially suited for web development. The unique thing about PHPis that it serves both beginners as well as experienced developers. It has a low barrier to entry soit is easy to get started with, and at the same time, it provides advanced features offered in otherprogramming languages.Open-SourceIt's an open-source project. Feel free to get involved.Language SpecificationPHP has a language specification.Supported VersionsCurrently, there are three supported versions: 5.6, 7.0 and 7.1.Each release branch of PHP is fully supported for two years from its initial stable release. After thistwo year period of active support, each branch is then supported for an additional year for criticalsecurity issues only. Releases during this period are made on an as-needed basis: there may bemultiple point releases, or none, depending on the number of reports.Unsupported VersionsOnce the three years of support are completed, the branch reaches its end of life and is no longersupported.A table of end of life branches is available.Issue TrackerBugs and other issues are tracked at https://bugs.php.net/.Mailing ListsDiscussions about PHP development and usage are held on the PHP mailing lists.Official DocumentationPlease help to maintain or to translate the official PHP documentation.https://riptutorial.com/2

You might use the editor at edit.php.net. Check out our guide for contributors.VersionsPHP 7.xVersionSupported UntilRelease Date7.12019-12-0

Chapter 1: Getting started with PHP 2 Remarks 2 Versions 3 PHP 7.x 3 PHP 5.x 3 PHP 4.x 3 Legacy Versions 4 Examples 4 HTML output from web server 4 Non-HTML output from web server 5 Hello, World! 6 Instruction Separation 6 PHP CLI 7 Triggering 7 Output 8 Input 9 PHP built-in server 9 Example usage 9 Configuration 9 Logs 10