开发者

PHP no longer replaces {$value} in strings

I am having problem with my PHP coding lately. I used to code like this;

<?php
$value = "ipsum";
echo "{$value} lorem";
?>

Output : ipsum lorem

I don't know what happened but like 10 days / 2 weeks ago the same coding gives me following output;

{$value} lorem

Since this happened, I also can't use <? ?> tags, I have to use <?php ?> tags. I know tags are related to PHP.ini but I have no idea what to edit in PHP.ini to solve my output (echo / print) problem.

EDIT :

My problem is not php short tags. I just meant those 2 problems occurred together so I wanted to write it down. Considering this is the first time I heard and / or experienced such problem, I just wanted to write everything down.

EDIT 2:

My problem is solved开发者_开发问答 after uninstalling / re-installing (2 times, first one didn't help) xampp. I'm accepting Jeremy Banks answer as a solution. Please note that my problem's solution wasn't his answer but I had to chose an answer since there wasn't a possibility to close the question with a real reason.


By using quoting your strings with ' you're not allowing $variables to be interpolated into it. You need to quote with " for that to work.

<?php
$value = 'ipsum';
echo "{$value} lorem";
?>


That <? is short_open_tag. Look for that in PHP.ini That output problem, it's because single quotes doesn't recognize it. change it to double quotes

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜