0 votes
151 views
in PHP by
edited
the syntax should be <?php ?> why it is <? ?>

1 Answer

0 votes
by (98.9k points)

The syntax for PHP code traditionally uses <?php ?> for opening and closing tags. However, PHP also supports a short form <? ?> for opening and closing tags, and this is often referred to as the "short open tag" syntax.

The use of short open tags (<? ?>) can depend on the server configuration. Some servers may have this feature enabled, while others may have it disabled due to security considerations.

Despite its availability, the use of <?php ?> is generally recommended for better compatibility across different server environments. This helps ensure that your PHP code works consistently, regardless of the server's specific settings.

In summary, while <? ?> is a valid syntax, <?php ?> is the more widely accepted and portable form, making it a safer choice in most scenarios.

Related questions

0 votes
1 answer 116 views
asked Oct 9, 2022 in PHP by MrRam (2.0k points)
0 votes
1 answer 139 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

537 users

...