Tags? and ? interpreted as html comment

0

I'm having problems with an application where some <? ?> tags are being confused with html comments. Follow the code snippet.

<h3><?= $cadastros->num_rows(); ?> registro(s)</h3>

<? foreach($cadastros -> result() as $cadastro): ?>

In source code, it interprets the arrows as html comment.

    
asked by anonymous 16.08.2017 / 00:10

2 answers

2

Enable short_open_tag in php.ini

Search for "short_open_tag", find the line and change the setting value.

    
16.08.2017 / 00:18
0

The short_open_tag policy is likely to be disabled.

1) Make sure it is enabled:

  • Via the command line:

    php -i | grep short_open_tag

  • Via file .php :

    phpinfo ();

2) Find the .ini files to make changes:

php --ini

and will return something like:

Configuration File (php.ini) Path: /etc/php/7.1/cli
Loaded Configuration File:         /etc/php/7.1/cli/php.ini
Scan for additional .ini files in: /etc/php/7.1/cli/conf.d

3) Look for the no .ini being loaded in Loaded Configuration File , change the value of the short_open_tag directive;

4) Restart Apache

    
16.08.2017 / 04:13