PHP Type Declarations: make your PHP code easier to read, and simpler to use

Опубликовано: 28 Сентябрь 2024
на канале: Dave Hollingworth
4,968
236

PHP for Beginners course: ➤ https://davehollingworth.net/phpy
PHP MVC course: ► https://davehollingworth.net/phpmvcy
CodeIgniter 4 course: ► https://davehollingworth.net/codeigni...

PHP is a dynamically-typed language. This means that variables don't have a fixed type. However, PHP does have an optional strong type system: type declarations (previously known as type hints). In this video we'll see how using this will make your code simpler, easier to read, and easier to maintain.

Resources:
https://www.php.net/manual/en/languag...
https://www.php.net/manual/en/languag...
https://www.php.net/manual/en/languag...

Code shown in the video:
https://gist.github.com/daveh/24e87e3...

00:00 Intro
00:30 Types in PHP
00:49 Type juggling
02:00 Function arguments
04:40 Type declarations
07:05 Strict type mode
08:15 Available types
08:46 Return values
09:00 Class properties
09:20 Union types
09:30 Nullable
10:02 Summary

#PHP #PHP8