PHP Reference

May 1, 2020

Traits

Kind of like Mixins?

PHP Docs: https://www.php.net/manual/en/language.oop5.traits.php

PHP only supports single inheritance: a child class can inherit only from one single parent. So, what if a class needs to inherit multiple behaviors? OOP traits solve this problem.

Traits are used to declare methods that can be used in multiple classes. Traits can have methods and abstract methods that can be used in multiple classes, and the methods can have any access modifier (public, private, or protected).

W3 Schools:https://www.w3schools.com/php/php_oop_traits.asp

Single Inheritance

PHP only supports single inheritance: a child class can inherit only from one single parent.

Source: https://www.w3schools.com/php/php_oop_traits.asp

Regular Expressions

See preg_match here

Composer Autoload

I couldn't understand why my local dev classes were not being auto loaded. I found the reason why here. I added the following to my composer.json. The "name" is what all your autoloaded classes are started with and the "src/" is where all your project code is.

name\path\to\class

  "autoload": {
    "psr-4": {
      "name\\": "src/",
    }
  },
Personal Updates

This is a password protected section available to those who know me in some fashion. If you know me and you do not already have a login, you can request a login here.

Personal Updates
Book Reviews

I am nuts about books. I read on all kinds of topics. I attempt to review each book I read for the sake of my own enrichment as well as conversation starters with others.

My Book Reviews
Pastoral Ministry

God has called me to be a pastor, and occasionally I have some pastoral thoughts I like to share.

Pastoral Posts
The Attic

You never know what you will find in an attic! Usually there is a hodgepodge of things buried under dust.

Explore the Attic
Technology

Most of what is included here are notes to myself. The majority of folks will not find interest in these posts.

Technology Posts