Why <? =?> Works on one computer, but not on another?

When I write

<?=?>

it doesn’t work on my PC, but it works on another PC !!! Why ??? :( for example:

<?php
$courses = CourseManager::findAll();
?>
<h3>Course List</h3>
<table>
    <tr><th>Name</th></tr>
 <?php   foreach ($courses as $c){
?>
    <tr>
        <td><?=$c->getName()?></td></tr>
  <?php } ?>

</table>

or is it too simple not? :)

<?= expression ?>

This is a shortcut for

<? echo expression ?>

or

<?php
$i ="test";
?>

<h1><?=$i?></h1>

Thanks for your advice:)

+3
source share
5 answers

You have no short tags.

To enable search short_open_tagin php.ini. Change it to "On" and restart Apache.

+5
source

PHP short_open_tag options do not match on different servers. If possible, avoid using these types of open tags.

, , ini_set.

+5

Check short_open_taginphp.ini

0
source

Since these shortcuts can be disabled in php.ini. This option is called short_open_tags.

0
source

Source: https://habr.com/ru/post/1760066/


All Articles