Netbeans has a great code formatting feature, the command is here: Source -> Format (ALT + SHIFT + F)

This perfectly formats the code (HTML, PHP, CSS, JS ...), but not in the case of multi-language (PHP + HTML) code — in this case, formatting most often does not give a good result .

Example code: here

PHP + HTML is a reality of my work (I work with CMS Bitrix).

Is there an adequate solution to this problem?

  • divide the code into appropriate files. - Jean-Claude
  • This is one of the templates of the CMS Bitrix component, it will not work there. Look at the code and everything will become clear. - Sergey

2 answers 2

They might want me, but I would advise using mvc to avoid mash in the code from the php inserts, then you can use <?= $out_var ?> and not do everything in the view.

  • Example code: yadi.sk/d/e_MFK2aT3QBZAB - Sergey
  • I can not see now I'm going on the bus - ishidex2
  • Well, as I said, you have a mix of sampling, control, and data mapping. First you need to read about MVC - ishidex2

Select only the formatted part of the code, and you will be happy. And better read the style recommendations, known as PSR-0, PSR-1 and PSR-2.

  • Sample code (someone else's code, but you have to work with it): yadi.sk/d/e_MFK2aT3QBZAB - Sergey
  • there is a question about something else, nafig generally format something, if ide does it for you. - Jean-Claude
  • This code in Netbeans after formatting in many places of the curve, and I format it because without formatting it is generally terrible (it was written before me). - Sergey