Naming php files

前端 未结 6 611
闹比i
闹比i 2021-02-02 14:08

Is there any convention for naming php files? Not talking about php class files, but files that are mostly HTML with some php inside them. Should it be my-file-example.php

6条回答
  •  清歌不尽
    2021-02-02 14:36

    There are usually 2 conventions you need to take into consideration:

    1. used framework
    2. PSR-4

    In best scenario these 2 are the same. I usually try to avoid cases when a framework tries to force some custom rules.

    Either way, the MOST important is to stay consistent throughout the project. Once you pick a convention to follow, stick with it until you start working on a different project. There's nothing worse than different naming conventions in a single project, doesn't matter if we're talking about files, classes, methods or whatever. Be consistent.

提交回复
热议问题