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

5 Answers 5

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.

Sign up to request clarification or add additional context in comments.

Comments

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

2 Comments

So it's best to go through the document and replace with echos?
It will be longer but better.
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:

Comments

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 

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.