Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does <?=?> work on one computer but not another?

When I write

<?=?>

in my PC it's not working,but it's work in 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 this, it's too simple no ? :)

<?= expression ?>

This is a shortcut for

<? echo expression ?>

or

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

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

Thanks for your advice :)

like image 579
Freeman Avatar asked Dec 17 '22 22:12

Freeman


1 Answers

You don't have the short tags enabled.

To enable them look for short_open_tags in php.ini. Change it to "On" and restart Apache.

like image 104
codaddict Avatar answered Jan 03 '23 20:01

codaddict