0

I have a PHP page like this:

<?
... Some PHP code here ...
?>
<html>
    <head>
        <script>
            ... Some JavaScript code here ...
            <?= $someVariable ?>
            ... Some more JavaScript code here ...
        </script>
    </head>
    <body>
    </body>
</html>

The thing is that the code:

<?= $someVariable ?>

Appears unchanged in the resulting HTML: its not executed or rendered. However, the initial PHP section executes normally (I verified this fact by adding "echo" calls in the first PHP block).

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
German Latorre
  • 10,058
  • 14
  • 48
  • 59

3 Answers3

5

Use full syntax <?php ... ?>

If you have PHP lower than 5.4 you can enable in php.ini shorttag set "short_open_tag" to "On"

From PHP 5.4 you can use shortags, regardless of shorttags settings

Ozerich
  • 2,000
  • 1
  • 18
  • 25
3

You're using a feature called Short Tags, which is often disabled by default. Replace those tags with <?php print $someVariable ?> or enable short tags.

Community
  • 1
  • 1
Eli
  • 5,500
  • 1
  • 29
  • 27
0
<?php echo $someVariable; ?>
Afshin
  • 4,197
  • 3
  • 25
  • 34