views:

45

answers:

4

I'm reading the book "PHP for absolute beginners" and I got to the part which says that this peace of php code:

<?='Weird'?>

yields the text inside quotes.

But this isn't the case for me and I'm not sure why.

Anyone knows the problem?

I'm using Apache/mySQL (XAMPP) and Eclipse.

+7  A: 

There is a server config to enable or disable short tags. http://php.net/manual/en/ini.core.php

tag is short_open_tag and is located in the php.ini file

David Young
Thanks this fixed it.
Tool
+1  A: 

It's recommended that you do not use short tags. :)

They're usually disabled.

Xorlev
So what? just enable it
Col. Shrapnel
And what if you can't? What if you're using shared hosting, pedestrian as it may be in the age of VPSes. It's best to shoot for highest compatibility.
Xorlev
+1  A: 

<?= ... ?> is a shorthand for <?php echo ... ?>. As other answers mentioned, they need to be enabled through the short_open_tag ini directive (which will also enable <? ... ?> as a shorthand for <?php ... ?>. Alternately, you can enable it locally within your script by using ini_set.

Daniel Vandersluis
are you sure about ini_set?
Col. Shrapnel
A: 

Please open php.ini and change short_open_tag to on.

shafqat