4

I have just downloaded a PHP blog script and am having a few issues with the syntax used in it.

There are several instances when this code occurs:

<?=$miniblog_posts?>

Now this doesn't do anything. To get it to work I have to change it to this.

<?php echo $miniblog_posts; ?>

Is this an old way of writting php that is not supported anymore or am I missing something.

I am running PHP V5.3.1

kero
  • 10,647
  • 5
  • 41
  • 51
Samuel Meddows
  • 36,162
  • 12
  • 38
  • 36

5 Answers5

6

http://php.net/manual/en/function.echo.php

See the shortcut syntax doc.

echo() also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. This short syntax only works with the short_open_tag configuration setting enabled.

Jan Zyka
  • 17,460
  • 16
  • 70
  • 118
4

Yeah it's called short open tags and now are disabled by default. You can change your configuration to enable them but it's not recommended, cause they will be removed from PHP next version (probably in php 5.4)

Configuration and severals stuffs are detailed in this page : http://php.net/manual/ini.core.php

Brice Favre
  • 1,511
  • 1
  • 15
  • 34
2

You have to enable short tag in php.ini to make <?=$miniblog_posts?> workable.

short_open_tag=On

Here are some related posts which may also help you to understand this:

Community
  • 1
  • 1
Naveed
  • 41,517
  • 32
  • 98
  • 131
1

I think you may need to turn on short_open_tag in php.ini file. Or you can config at .htaccess . Like

short_open_tag on 
Thurein Soe
  • 178
  • 3
  • 8
1

The PHP Shorthand notation <?= ?> depends on the php.ini, you should change the state to allow short open tag. Whereas the code <?php ?> can run everytime everywhere, without any configuration.

Balanivash
  • 6,709
  • 9
  • 32
  • 48