PHP #region for code folding?

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

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

15条回答
  •  南笙
    南笙 (楼主)
    2021-01-31 14:57

    There is no equivalent (the other answers explain why), but let me show you how I do it:

    //////////////////////////
    /* REGION A */ {
    
        function SomeFunction() {
            return true;
        }
    
        function AnotherFunction() {
            return false;
        }
    
    }
    
    //////////////////////////
    /* REGION B */ {
    
        function ThirdFunction() {
            return true;
        }
    
        function FourthFunction() {
            return false;
        }
    
    }
    

    The curly braces allow me to fold the block of code (your editor will need to support cold folding, but almost all of them do), while I still see the region name and have a simple visual divider.

    Folded Result:

    //////////////////////////
    /* REGION A */ { 
    
    //////////////////////////
    /* REGION B */ { 
    

提交回复
热议问题