为什么我们使用起始和结束标记为<? 在PHP中?

I am using php and from the beginning i was wondering about the thing that why we use <? ?> tag as starting and ending of the php tag.

I know its scripting used for differentiating php from other language but i want to know that why we use and not any other tag as the starting and ending tag?

<% and %> are only supported on some servers. The usual PHP tags are <?php and ?> and these are the ones you should use.

In fact, we don't use <% and %> tags. Theses tags are used by ASP scripts, and there is a special configuration in php.ini to use asp-like tags. PHP use <?php and ?> tags (or <? ?> in shorter form). In pure PHP files the closing tag in not required.

Why using <% ? Maybe because <? is the beggining of an XML file too, so it can be confusing for parsers, but not for standard web server as PHP files never be sent to browsers.

correct tag for php are <?php ?>.

<% %> are opening/closing tag for ASP script (vbscript and other microsoft languages).
However, some misconfigured php installations accept those also for php, but try to avoid this usage as you may have some trouble if you want to run your script on an other server.

To be complete, the closing tag ?> is useless if you script contain only php code. It's event recommended to not using it, to avoid problem when you play with cookies ...

This is one of the stupidest things in the php community. The accepted practice as stated by others is to use <?php ?> and to print a variable, <?php echo $foo ?> I suspect this was originally out of spite to not be confused with ASP's <% %>

Which is easier to read? RoR's <%= foo %> or <?php echo $foo; %> I think most non-php people would opt for the shorter one.

In addition, there is an argument that <% %> breaks XML parsers, whereas <? ?> passes through them. I think that is a silly argument, because a php file is not an XML file... You would parse the XML produced by running through php first, which would no longer have the php markers. Why would you run php through an xml parser? Would you run a C++ file through an XML parser?