Hi,
I my code i am using open tag like this <?PHP its working fine but if i use <? that time its showing entire code its not showing html pages

Please can anyone tell me how to fix this problem

Regards
Punitha pary

Recommended Answers

All 6 Replies

it is a setting in the config file. it is recommended to use the long tag.

There are several solutions to this problem. You could modify your php.ini file to allow php short tags. Or if you don't have access to the core php.ini file you can add the following code to the very top of your document.

<?php ini_set('short_open_tag',1); ?><?

You can enable short tags, however, there are other servers (like yours) which do no have the short tags option on.

This means that if you deploy the code onto another server, it may not run.
As pritaeas says, it is recommended to the the full <?php opening tag. There is no real reason not to use them.

I think the main reason why people prefer short tags is that they are faster to type with 60% less letters/symbols to type. Also they look neater but as previously mentioned, it is best to use <?php for compatibility as I think short tags a depreciated in php6.

It's true that short tag has less character to type. But there are many well PHP editor out there, which automatically create a proper <?php ?> syntax with a single click or via hotkey.

It's true that short tag has less character to type. But there are many well PHP editor out there, which automatically create a proper <?php ?> syntax with a single click or via hotkey.

But then how many people RTFM to find out what those hotkeys are? Probably find rarely are hotkeys used even if they are available. Also I think some people might like how it is possible to make the opening tag look a lot like the closing tag which is clean and simple. That is what would make people use short tags a lot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.