PHP #region for code folding?

No, there’s nothing directly in the language.

But every decent editors allow some kind of markup to allow this.

For example in Netbeans :

// <editor-fold defaultstate="collapsed" desc="user-description">
  ...any code...
// </editor-fold>

This syntax also works in all the Intellij IDEA editor family, see http://blog.jetbrains.com/webide/2012/03/new-in-4-0-custom-code-folding-regions/

You can also emulate the feature in Eclipse via a plugin : Code folding plugin for Eclipse?

Visual Studio Code includes it since version 1.19 :

#region user description
...any code...
#endregion

Leave a Comment