Tags < ? and ? > interpreted as html commentary

Asked

Viewed 167 times

-1

I’m having problems in 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 the source code, it interprets the arrows as html comment.

  • if I remember correctly.. in the new versions of php there has been a change in the simplification.. if I am not mistaken, it should now be used <?= ? > to simplify, and there at the beginning of your foreach there. ta missing the same.. to stay.. <?=

  • I already tested with the <?= E of the foreach error.

  • friend, put all the code of your foreach to see... usually I do a foreach opening and closing { } .. hugs

  • <? foreach($entries -> result() as $cadastro): ? ><! -error-> <tr> <td><?= $cadastro->id ? ></td> <td>?= $registration->name ? ></td> <td><?= $registration->phone ? ></td> <td>?= $registration->email ? ></td> <td>?<= $registration->observations ? ></td> <td><?= Anchor("registration/Edit/$registration->id", "Edit") ? > | <a href="#" class='confirma_exclusion' date-id="<?= $registration->id ? >" name-date="<?= $registration->name ? >" />Delete</a></td> </tr> <? endforeach; ?>

  • tested on an external server and worked properly

  • edit your first post and enter the code for foreach la.. so it’s rum de ver.. This server you tested uses which version of php?

Show 1 more comment

2 answers

2

Enable the short_open_tag in php.ini

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

0

Likely that the Directive short_open_tag is disabled.

1) Check that it is activated:

  • Via command line:

    php -i | grep short_open_tag

  • Via file .php:

    phpinfo();

2) Find the files .ini to effect change:

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) Search for in .ini that is being loaded into Loaded Configuration File, changes the value of the Directive short_open_tag;

4) Restart the Apache

Browser other questions tagged

You are not signed in. Login or sign up in order to post.