8 Février 2021 à 08h18 - 9543

Ways to code the same in PHP

Advent of Code is a programming exercise advent calendar. Every day a new one, and the difficulty gradually rises. It's completely free, just create an account to participate. Each retrieves a set of data of its own each day and must therefore submit THE associated response, which is always a numeric value to find. Each day offers 1 exercise broken down into 2 levels of difficulty, one affordable, and another much more complicated ... The choice of language is free since we simply retrieve an input in text format. It will therefore be necessary to resolve the problem locally.

Typing in PHP Well, it's been around for a long time, but a reminder doesn't hurt. As I started coding without typing in PHP, I wasn't always strict about this aspect. But now I can't do without. In php web development, it is possible to type: The parameters of a function or method The return of a function or method The properties of a class

We could ask ourselves "what is the point of typing"? Typing will allow you to strengthen and secure your code. Indeed, PHP throws a fatal error if the typing is not respected. For a method, no more need to test the nature of the parameter (s), PHP will do it directly. If you structure a function with a precise expected return type, if the function evolves and this return changes, similarly, PHP raises a fatal error. This is just a taste of what you can do with typing, so please refer to the official documentation for more information.

Respect the protections in the classrooms

This is a question of good practice. As with typing, this best practice allows you to strengthen and secure your code. You create a new class, declare it as "final". You create properties or methods, declare them as "private". And you only change if you need to, that way you have a class that is always secure.


  1. 4 Fév. 2022Antminer S19 XP Crypto Mining Machine Surprise!2176
  2. 1 Fév. 2022What PHP Website Developers Do: The Job Description and What Skills They Need718
  3. 2 Janv. 2022The Different Important Skill Sets and Positions Required for a PHP Web Development Company1553
  4. 22 Déc. 202110 Reasons Why You Might Need a PHP Programming Service1239