1

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.

i need help
  • 2,386
  • 10
  • 54
  • 72
  • Hey, can you put a little text formatting in your quesion? It'll make it much easier to read. –  Jul 29 '09 at 16:22

6 Answers6

4

<?= 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?

Community
  • 1
  • 1
jimyi
  • 30,733
  • 3
  • 38
  • 34
3

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
  • 49,547
  • 13
  • 120
  • 153
1

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
  • 57,217
  • 21
  • 114
  • 142
1

Short tags (<?) have been deprecated.

dnagirl
  • 20,196
  • 13
  • 80
  • 123
0

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

Gumbo
  • 643,351
  • 109
  • 780
  • 844
0

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