Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP #region for code folding?

Tags:

php

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

like image 302
mattdwen Avatar asked Apr 10 '11 23:04

mattdwen


People also ask

What PHP stand for?

PHP, originally derived from Personal Home Page Tools, now stands for PHP: Hypertext Preprocessor, which the PHP FAQ describes as a "recursive acronym." PHP executes on the server, while a comparable alternative, JavaScript, executes on the client.

Is PHP a coding?

PHP is an open-source server-side scripting language that many devs use for web development. It is also a general-purpose language that you can use to make lots of projects, including Graphical User Interfaces (GUIs).

Is PHP used anymore?

PHP is known to be the most frequently used programming language. According to W3Techs, 78.8% of all websites are using PHP for their server-side. Interesting fact: PHP originally stood for Personal Home Page. Now PHP is widely known and thought of as Hypertext Preprocessor.


2 Answers

No.

The thing is, C# is sort of designed to be written by only one IDE, because Microsoft need you to always use their tools. So, built into the language (sort of) are things that affect the IDE.

PHP, on the other hand, is just a language. It's not supposed to have a symbiotic relationship with some specific editor, so it doesn't. So, no, it has nothing to control your editor.

Still, all proper programming text editors support folding class definitions, function definitions, and most scope blocks. Some editors may allow certain extensions to go beyond this.

like image 32
Lightness Races in Orbit Avatar answered Oct 11 '22 09:10

Lightness Races in Orbit


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 
like image 155
krtek Avatar answered Oct 11 '22 10:10

krtek