0

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.

Revenant
  • 2,942
  • 7
  • 30
  • 52
  • To solve the " ?>" issue: http://stackoverflow.com/questions/2185320/how-to-enable-php-short-tags –  Sep 16 '11 at 22:56
  • I know how to fix it. I just meant out of sudden something happened to my php.ini and I got problem with ?> tags along with output problem. – Revenant Sep 16 '11 at 22:58
  • Maybe php is using another php.ini. Use phpinfo to see the location... –  Sep 16 '11 at 23:00
  • No, it is the correct php.ini Come to think once again, I have tried to install newer version of xampp. My system created some small problem didn't want to fix my codes and installed the old version of xampp again. I would think that might be the reason but everything went smooth for a week at least. I am truly lost now. – Revenant Sep 16 '11 at 23:06
  • I re-installed xampp (2 times, first one didn't work) and now it is working without any problems. I still don't understand the reason but re-installing helped. – Revenant Sep 17 '11 at 08:57

2 Answers2

5

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";
?>
Jeremy
  • 1
  • 85
  • 340
  • 366
0

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

genesis
  • 50,477
  • 20
  • 96
  • 125
  • I know how to fix it. I just meant out of sudden something happened to my php.ini and I got problem with ?> tags along with output problem. I need to solve the output problem not this one but thank you for your help. – Revenant Sep 16 '11 at 22:58