tags:

views:

111

answers:

6
+1  Q: 

php syntax issue?

value="<?=$file_source?>"> it will show the >"> at my browser

but if

value="<?php echo $file_source?>"> it will show correctly in browser.

Is it due to php versioning?

Also I realize some php classes written by others (which I download online), doesn't use <?php ?> , it directly use <? ?>

But when I run it locally at xampp, I need to code it as in order to get the correct output.

+4  A: 

<?= and <? are PHP short tags. They don't work because it is not enabled in your PHP config, and it is generally recommended to avoid using them and always use <?php

See Are PHP short tags acceptable to use?

jimyi
+1  A: 

You need to enable short_open_tag in your PHP configuration. People tend to think this a bad idea, although the short echo sytax is very useful.

This directive also affects the shorthand <?= , which is identical to <? echo . Use of this shortcut requires short_open_tag to be on.

http://php.net/manual/en/ini.core.php

Tom Haigh
A: 

It seems that short_tag_open is disabled and thus any other PHP open tags except <?php are ignored.

Gumbo
+1  A: 

Short tags (<?) have been deprecated.

dnagirl
+3  A: 

PHP has a short_open_tag directive in php.ini which needs to be on for <? ... ?> and <?= ... ?> to work. However, the recommendation is to only use <?php ... ?> in your code.

So, for your code to work you will need to either turn short_open_tag on, or change the code to use <?php ... ?>.

Blixt
A: 

What you can also do, if you're not sure about the php.ini, create .htaccess file.

From notepad, save the file and called it '.htaccess'

In that file, put short_open_tag On