PHP Pages

The PHP File Type, which uses the PHP Page language parser, supports PHP with embedded HTML, plus cli­ent-side script. PHP scripting blocks will appear using the syntax formatting for PHP, and the appropriate for­matting for client-side script elements. PHP symbols are also displayed in the symbol window, and are saved in the symbol database. The Relation Window will show references and call trees for PHP symbols.

Source Insight supports the PHP script start tokens: <? and <?= and <?php . The PHP end script token is ?>. The deprecated <% and %> tokens are not supported. Source Insight parses both the script and the HTML.

To populate the symbol information, Source Insight parses multiple streams from the same file: one for the server side PHP and one for the client side HTML. In addition, the client side may contain HTML script ele­ments. Given the way PHP pages are typically written, the HTML elements from a PHP page file usually are parsed and recognized by Source Insight. However, it is not guaranteed to work, since PHP fragments can emit conflicting HTML tags, or they can be out of order.

You may notice in Options > Preferences: Languages, that there is a separate PHP Language which is not bound to a file type. This is responsible for parsing pure PHP code, and does not understand interleaved HTML at all. A separate language type: The PHP Page parser brokers the HTML and PHP server-side pieces to either the HTML or PHP Language.