S
S
Sergey Korenevsky2016-08-03 16:06:08
PHP
Sergey Korenevsky, 2016-08-03 16:06:08

How to write code to collapse its snippets in NetBeans?

I got a long method in the class. I use NetBeans for editing.
What special characters should be used for code folding, as in, for example, in the function: if, foreach?
In C#, the #region code was used for this

<?php
#region Комментарий.
echo " Рабочий код ";
#endregion;

thus the contents of this #region were hidden, only the comment was visually displayed.
<?php
#region Комментарий и скрытый код.

but the content of the region was the working program for PHP.
Are there such tags for NetBeans PHP in the code or in general for PHP?
There is a solution : wiki.netbeans.org/FaqCustomCodeFolds
(select a piece of code -> click on the light bulb -> click on
// <editor-fold defaultstate="collapsed" desc="comment">

and the text is wrapped in // < editor-fold defaultstate="collapsed" desc="comment"> like this is a comment with this tag.
And it can be hidden

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Koryukov, 2016-08-03
@MadridianFox

If you have a huge sheet of code that doesn't contain "natural" regions to hide, then something is wrong with your code.
The best practices of all popular programming languages ​​say that the body of the function should fit on the screen, and sometimes even be no more than 10-15 lines.
There are times when large chunks of code are justified, but if you have them so often that you need a way to wrap them up...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question