Skip to content

katheroine/php.lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

622 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP.lab 🐘

A curated knowledge base and laboratory for PHP engineering.

Index

Description

  1. What is PHP?
  2. PHP history
  3. PHP features
  4. PHP code
    1. Literals, constants, variables
      1. Literals
      2. Constants
      3. Variables
    2. References
    3. Types
      1. Type system
      2. Type declarations
      3. Type juggling
    4. Expressions
    5. Operators
      1. Operator precedence
      2. Arithmetic operators
      3. Logical operators
      4. Bitwise operators
      5. Comparison operators
      6. Increment & decrement operators
      7. Assignment operators
      8. String operators
      9. Array operators
      10. Type operators
      11. Functional operator
      12. Execution operators
      13. Error control operators
    6. Control flow
      1. if conditional statement
      2. if-else conditional statement
      3. if-elseif-else conditional statement
      4. switch conditional statement
      5. match conditional statement
      6. while loop statement
      7. do-while loop statement
      8. for loop statement
      9. foreach loop statement
      10. break instruction
      11. continue instruction
      12. goto instruction
    7. Built-in types
      1. Special
        1. Null
        2. Resources
      2. Scalar
        1. Booleans
        2. Integers
        3. Floating point
        4. Strings
      3. Compound
        1. Arrays
        2. Objects
    8. Enumerations
    9. Functions
      1. Functions
      2. Anonymous functions
      3. First class callable syntax
    10. Generators
    11. Fibers
    12. Classes, interfaces, traits
      1. Classes
        1. Classes
        2. Class members
        3. Magic methods
        4. Constructors and destructors
        5. Objects
        6. Inheritance
        7. Anonymous classes
        8. Autoloading classes
      2. Abstract classes
      3. Interfaces
      4. Traits
    13. Errors and exceptions
      1. Errors
      2. Exceptions
    14. Attributes
    15. Reflections
    16. Namespaces

Examples

  1. PHP features
    1. Loosely typed language
    2. Dynamically typed language
  2. PHP code
    1. Literals, constants, variables
      1. Literals
      2. Constants
        1. Defining constants
        2. Types in constant definitions
        3. Expressions in constant definitions
        4. Accessing constants
        5. Scope of the constants
        6. Functions handling constants
          1. define function
          2. defined function
          3. constant function
          4. get_defined_constants function
      3. Variables
        1. Defining variables
        2. Types in variable definitions
        3. Accessing variables
        4. Assigning to the variables
        5. Destroying variables
        6. Scope of the variables
          1. Global variables
          2. Global variable in an included file
          3. Variable from a file included within a function
          4. Variable binding to a closure
          5. Static variables
          6. Static variables and an inheritance
        7. Functions handling variables
          1. isset function
          2. unset function
          3. get_defined_vars function
    2. Types
      1. Types of the function arguments
      2. Types of the function return
      3. Strict type control
      4. Functions handling types
        1. gettype function
        2. settype function
    3. Operators
      1. Arithmetic operators
        1. Modulo operator
      2. Increment & decrement operators
      3. Assignment operators
        1. Basic assignment operator
        2. Null coalescing assignment operator
        3. Assignment expression value
      4. Bitwise operators
        1. Bitwise shift operators and conversions
      5. Comparison operators
        1. Strict equality & inequality operators
        2. Three-way comparison (spaceship) operator
        3. Ternary operator
          1. Ternary operator shorthand
          2. Ternary operator and conversions
          3. Nested ternary operators
        4. Spaceship operator
        5. Null coalescing operator
          1. Null coalescing operator and conversions
          2. Nested null coalescing operator
      6. Logical operators
      7. Type operator conversions
      8. Nullsafe operator
    4. Control flow
      1. if conditional statements
        1. if conditional statement
        2. if alternative syntax
        3. if formatting
        4. if-else conditional statement
        5. if-else alternative syntax
        6. if-else formatting
        7. if-elseif-else conditional statement
        8. if-elseif-else alternative syntax
      2. switch conditional statement
        1. switch conditional statement
        2. switch alternative syntax
      3. match conditional statement
      4. while loop statements
        1. while loop statement
        2. while formatting
        3. do-while loop statement
        4. do-while formatting
      5. for loop statement
        1. for loop statement
        2. for alternative syntax
        3. for formatting
      6. 'foreach` loop statement
        1. 'foreach` loop statement
        2. 'foreach` alternative syntax
        3. 'foreach` formatting
      7. break instruction
      8. continue instruction
      9. goto instruction
    5. Built-in types
      1. Special
        1. Null
          1. Null
          2. Null syntax
          3. Null use cases
            1. Undefined value
            2. Database query with no result
          4. Testing for null
          5. Null as unset effect
          6. Casting from null
        2. Resource
          1. Resource
          2. Checking resource type
      2. Scalar
        1. Booleans
          1. Bool
          2. Bool syntax
          3. Bool use cases
            1. Comparison result
            2. Control structures
          4. Testing for bool
          5. Logical context
          6. Logical context and equal operator
          7. Casting to bool
          8. Casting from bool
          9. Automatic conversions to bool
        2. Integers
          1. Int
          2. Int syntax
          3. Int use cases
            1. Quantity
            2. Index
          4. Testing for int
          5. Binary, octal, decimal and hexagonal integer notation
          6. Int values range
          7. Casting to int
          8. Casting from int
        3. Floating point
          1. Float
          2. Float syntax
          3. Float exponential notation
          4. Float use cases
            1. Measure
            2. Calculation
          5. Testing for float
          6. Float values range
          7. NaN
          8. Infinity
          9. Casting to float
          10. Casting from float
        4. Strings
          1. String
          2. String syntax
          3. Escape sequences
          4. String use cases
            1. Text processing
            2. Text statistics
          5. Testing for string
          6. String interpolation
          7. Basic types formating in strings
          8. String length and word count
          9. Numeric strings
          10. String concatenation
          11. String trimming
          12. String cases
          13. Casting to string
          14. Casting from string
      3. Compound
        1. Arrays
          1. Array
          2. Array syntax
          3. Array definition and initialisation
          4. Array assignment and overwriting
          5. Array creating
          6. Array displaying
          7. Array modifying
          8. Array destroying
          9. Array values
          10. Array keys
          11. Array key type casting and overwriting
          12. Array elements
          13. Array element appending with array access operator
          14. Array elements creating
          15. Array elements accessing
          16. Array elements modifying
          17. Array elements destroying
          18. Indexed arrays
          19. Associative arrays
          20. Nested arrays
          21. Testing for array
          22. Array destructuring
          23. Array unpacking
          24. Array unpacking and key overwriting
          25. Array merging
          26. Array merging and key overwriting
          27. Array adding
          28. Array adding and key overwriting
          29. Array combining
          30. Array comparing
          31. Array sorting
          32. Array size
          33. Array internal pointer
          34. Iterating over array_and_reading elements
          35. Iterating over array and updating elements
          36. Passing array to the function
          37. Casting to array
          38. Casting from array
        2. Objects
          1. Object
          2. Object definition and initialisation
          3. Object assigning and overwriting
          4. Object creating
          5. Object displaying
          6. Object modifying
          7. Object destroying
          8. Object properties
          9. Object properties defining and initialising
          10. Dynamic properties
          11. Object properties accessing
          12. Object properties updating
          13. Testing for object
          14. Casting to object
          15. Casting from object
    6. Enumerations
      1. Enum
      2. Enum use cases
        1. Constant set of states
        2. Set of options in the contract
      3. Basic enums
      4. Backed enums
      5. Enum case values linsting
      6. Enum constants
      7. Enum methods
      8. Enum static methods
      9. Enum implementing interface
      10. Enum using trait
      11. Enum case as constant value
      12. Enum case in constant expression
      13. Casting from enum case
    7. Functions
      1. Function
      2. Function variations
      3. Functions possible formatting
      4. Function with function definition
      5. Function with class definition
      6. Function call before definition
      7. Function conditional call after conditional definition
      8. Function calling function
      9. Function global scope
      10. Function arguments
      11. Passing arguments by value
      12. Passing arguments by reference
      13. Passing arguments
      14. Function arguments dafault value
      15. Function arguments variable number
      16. Function named arguments
      17. Function returning value
      18. Function with static variable
      19. Variable function
      20. Anonymous function (lambda)
      21. Anonymous function variations
      22. Closure
      23. Closure variations
      24. Closure binding by value
      25. Closure binding by reference
      26. Closure binding $this
      27. Static anonymous function
      28. Arrow function
      29. Arrow function binding
      30. Function as variable
      31. Callbacks
      32. Callbacks formatting
      33. Higher order functions
    8. Generators
      1. Generator
      2. Generator yielding values
      3. Generator yielding key - value pairs
      4. Generator yielding null
      5. Yielding element by value
      6. Yielding element by reference
      7. Generator calling generator
      8. Yielding from array
      9. Yielding from array with keys
      10. Yielding from generator
      11. Yielding from generator with keys
      12. Yielding from and keys collision
      13. Generator returning value
    9. Classes, interfaces, traits
      1. Classes
        1. Classes
          1. Class
          2. Class definition
          3. Class instantiation
          4. Class instantiation from a string
          5. Class instantiation from an expression
          6. Class instantiation from static, self and parent keywords
          7. Class instatiation by a factory method
          8. Class instantiation ways
          9. Object assigning to the variable, passing to the function and returning by the function
          10. Object access
          11. Class instatiation and immediate instance member access
          12. Readonly class
          13. Readonly class inheritance
          14. Class inheritance
          15. Class inheritance and class name resolution
          16. Class inheritance and covariance, contravariance, inheritance
          17. Class name resolution
        2. Class members
          1. Class members
          2. Class static members
          3. Class member visibility
          4. Class member visibility from the same class object
          5. Class members static access
          6. Class members dynamic access
          7. Class member access by static, self and parent keywords
          8. Class constant
          9. Class constant visibility modifiers
          10. Class constant type declarations
          11. Class property
          12. Class static property
          13. Class property definition
          14. Class property definition required modifier
          15. Class property visibility modifiers
          16. Class property declaration default visibility
          17. Class property asymetric visibility
          18. Class property asymetric visibility and inheritance property redefinition
          19. Class property type declarations
          20. Nullsafe properties
          21. Class property access
          22. Class typed property initialisation before access
          23. Class readonly property
          24. Class readonly property initialisation
          25. Class readonly property initialisation scope
          26. Class readonly property initialisation during cloning
          27. Class readonly property visibility
          28. Class readonly property interior mutability
          29. Class dynamic property
          30. Class method
          31. Class static method
          32. Class method visibility modifiers
          33. Class method visibility and polimorphism
          34. Class method type declarations
          35. Nullsafe methods
          36. Property and method with the same name
          37. Anonymous function property and method with the same name
          38. Class backed property hook
          39. Class asymetric backed property hook
          40. Class backed property hook contravariance
          41. Class backed property hook shorthand omitted parameter type
          42. Class backed property hook shorthand expression
          43. Class backed property hook and constructor promotion
          44. Class virtual property hook
        3. Constructors and destructors
          1. Constructor and destructor
          2. Constructor
          3. Constructor arguments
          4. Constructor promotion
          5. Constructor promotion property modifiers
          6. Constructor promotion property type declarations
          7. Constructor and inheritance
          8. Private constructor
          9. Destructor
          10. Destructor and inheritance
        4. Objects
          1. Class object
          2. Class object definition and initialisation
          3. Class object modifying
          4. Iterating over object and reading properties
          5. Iterating over object and updating properties
          6. Class object comparing
          7. Class object serializing
          8. Class object cloning
          9. Class object and reference
          10. Lazy ghost
          11. Lazy proxy
        5. Inheritance
          1. Class inheritance
          2. Extending class
          3. Base and derived class
          4. Multilevel inheritance
          5. Encapsulation
          6. Polimorphism
          7. Class inheritance and members visibility
          8. Class members visibility modifiers
          9. Class constant overriding and visibility
          10. Class property overriding and visibility
          11. Class static property overriding with visibility
          12. Class method overriding with visibility
          13. Class static method overriding with visibility
          14. Class inheritance and method overriding
          15. Class property hook overriding with visibility
          16. Class final constant
          17. Class final property
          18. Class final method
          19. Class final property hook
          20. Class constant access with visibility
          21. Class final constant access with visibility
          22. Class property access with visibility
          23. Class static property access with visibility
          24. Class readonly property access with visibility
          25. Class final property access with visibility
          26. Class method access with visibility
          27. Class static method access with visibility
          28. Class final method access with visibility
          29. Class property hook access with visibility
          30. Class inheritance and public members access
          31. Class members overriding and visibility compatibility
          32. Class method overriding and paramenter number compatibility
          33. Class method overriding and paramenter requireness compatibility
          34. Class method overriding and types compatibility
          35. Class property overloading
          36. Class method overloading
          37. Final class
          38. Static method call
          39. Non-static method call
          40. Forwarding method call
          41. Non-forwarding method call
          42. forward_static_call function
          43. self:: vs static:: member referencing
          44. static:: vs $this-> member referencing
        6. Anonymous classes
          1. Anonymous class
          2. Anonymous class with constructor
          3. Anonymous class extending class
          4. Anonymous class implementing interface
          5. Anonymous class using trait
          6. Readonly anonymous class
          7. Anonymouns class object class
          8. Anonymous class object as another class property
      2. Abstract classes
        1. Abstract class
        2. Abstract class without abstract members
        3. Abstract method
        4. Abstract property (hooks)
        5. Abstract class with abstract members
      3. Interfaces
        1. Interface
        2. Interface and dependency injection
        3. Implementing interface
        4. Interface constant
        5. Interface method
        6. Interface property (hooks)
        7. Multiple interface implementing
        8. Interface extending interface
        9. Extending class and implementing interface
        10. Interface implemented by abstract class
      4. Traits
        1. Trait
        2. Trait and reusability
        3. Trait members access
        4. Trait constant
        5. Trait property
        6. Trait static property
        7. Trait method
        8. Trait static method
        9. Trait abstract method
        10. Trait final method
        11. Multiple trait using
        12. Trait using trait
        13. Extending class and using trait
        14. Multiple trait using and conflict resolution
        15. Trait members visibility changing
    10. Errors and exceptions
      1. Errors
        1. Triggering and handling errors
        2. Catching errors
      2. Exceptions
        1. Exception
        2. Throwing an exception
        3. Throwing a defined exception
        4. Throwing an exception as an expression
        5. Catching an exception
        6. Catching a defined exception
        7. Catching an exception and ommiting the caught variable
        8. Catching exceptions of various types
        9. Catching an exception of multiple types
        10. Code always executed
        11. try-catch-finally
        12. Throwing and catching an exception and returning a value
        13. Nesting try-catch in try
        14. Nesting try-catch in catch
        15. Rethrowing an exception in the catch block
        16. Rethrowing an exception in the catch block and throwing an exception in the finally block
        17. Exceptions hierarchy
    11. Attributes
      1. Attribute
      2. Attributes
      3. Attribute with argument
      4. Repeatable attributes
      5. Function attribute
      6. Enum attribute
      7. Class attribute
    12. Reflections
      1. Function reflections
      2. Enum reflections
      3. Class reflections
      4. Class constant reflections
      5. Property reflections
      6. Method reflections
  3. Built-in constructs & library
    1. Functions
      1. Language constructs
        1. Class parents (SPL)
        2. Class implements (SPL)
        3. Class uses (SPL)
        4. Object ID (SPL)
        5. Object hash (SPL)
        6. SPL classes (SPL)
      2. Iterators
        1. Iterator count (SPL)
        2. Iterator to array (SPL)
        3. Iterator apply (SPL)
      3. Autoloadig
        1. Autoload functions (SPL)
        2. Autoload register (SPL)
        3. Autoload unregister (SPL)
        4. Autoload (SPL)
        5. Autoload extensions (SPL)
    2. Methods
      1. Magic methods
        1. __set
        2. __get
        3. __call
        4. __callStatic
        5. __invoke
        6. __isset
        7. __unset
        8. __sleep
        9. __wakeup
        10. __serialize
        11. __unserialize
        12. __toString
        13. __debugInfo
        14. __construct
        15. __destruct
    3. Classes
      1. Language constructs
        1. Closure
        2. Generator
        3. Array object (SPL)
        4. Standard class
        5. Weak reference
        6. Sensitive parameter value
      2. Data structures
        1. Doubly linked list (SPL)
        2. Stack (SPL)
        3. Queue (SPL)
        4. Priority queue (SPL)
        5. Max heap (SPL)
        6. Min heap (SPL)
        7. Fixed array (SPL)
        8. Object storage (SPL)
        9. Weak map
      3. Iterators
        1. Array iterator (SPL)
        2. Recursive array iterator (SPL)
        3. Iterator iterator (SPL)
        4. Recursive iterator iterator (SPL)
        5. Append iterator (SPL)
        6. Empty iterator (SPL)
        7. Limit iterator (SPL)
        8. No rewind iterator (SPL)
        9. Infinite iterator (SPL)
        10. Multiple iterator (SPL)
        11. Callback filter iterator (SPL)
        12. Recursive callback filter iterator (SPL)
        13. Caching iterator (SPL)
        14. Recursive caching iterator (SPL)
        15. Regex iterator (SPL)
        16. Recursive regex iterator (SPL)
        17. Filesystem iterator (SPL)
        18. Directory iterator (SPL)
        19. Recursive directory iterator (SPL)
        20. Glob iterator (SPL)
        21. Recursive tree iterator (SPL)
        22. Parent iterator
      4. Exceptions
        1. Exception
        2. Error
        3. Error exception
        4. Type error
        5. Invalid argument exception (SPL)
        6. Value error
        7. Argument count error
        8. Unexpected value exception (SPL)
        9. Bad function call exception (SPL)
        10. Bad method call exception (SPL)
        11. Arithmetic error
        12. Division by zero error
        13. Unhandled match error
        14. Assertion error
        15. Closed generator exception
        16. Logic exception (SPL)
        17. Length exception (SPL)
        18. Out of bounds exception (SPL)
        19. Out of range exception (SPL)
        20. Overflow exception (SPL)
        21. Underflow exception (SPL)
        22. Range exception (SPL)
        23. Domain exception (SPL)
        24. Runtime exception (SPL)
        25. Parse error
      5. Files
        1. File info (SPL)
        2. File object (SPL)
    4. Interfaces
      1. Data
        1. Stringable
        2. Serializable
      2. Collections
        1. Array access
        2. Countable (SPL)
      3. Iterators
        1. Traversable
        2. Iterator
        3. Seekable iterator (SPL)
        4. Iterator aggregate
        5. Outer iterator (SPL)
        6. Recursive iterator (SPL)
      4. Exceptions
        1. Throwable
  4. Standards
    1. Basic coding standard (PSR-1)
    2. Extended coding style (PSR-12)
    3. PER Coding Style 3.0
    4. Autoloading standard (PSR-4)
    5. Logger interface (PSR-3)
    6. Simple cache (PSR-16)
    7. Caching interface (PSR-6)

License

This project is licensed under the GPL-3.0 - see LICENSE.md.