PHP #region for code folding?

前端 未结 15 1455
星月不相逢
星月不相逢 2021-01-31 14:06

Is there an equivilent of c#\'s #region in PHP?

15条回答
  •  天涯浪人
    2021-01-31 14:48

    In Visual Studio Code, you can "feel at home" with c# style regions like this:

    #region Constants
        const ICEBERGS_PER_TITANIC = 100000000;
        const COFFEE_IV_DRIP_RATE = 0.00005;
    #endregion
    

    Technically, the region Constants isn't required, all it needs is the # sign. But for c# developers who are used to seeing this (because Visual Studio insists on it being this way), it's not really noisy. And it's actually self-documenting. A PHP maintenance programmer would not by stymied by this.


    Having said that, these ways also work, but it would be confusing (or just less clear) and might not work in another editor:

    #deathstar Constants
        const ICEBERGS_PER_TITANIC = 100000000;
        const COFFEE_IV_DRIP_RATE = 0.00005;
    #deathstar
    
    # Constants
        const ICEBERGS_PER_TITANIC = 100000000;
        const COFFEE_IV_DRIP_RATE = 0.00005;
    #
    

提交回复
热议问题