0 votes
4.0k views
in PHP by (98.9k points)
edited
Which of the following is the correct syntax to write a PHP code?
a) <?php ?>
b) < php >
c) < ? php ?>
d) <? ?>

2 Answers

0 votes
by
selected by
 
Best answer
Which of the following is the correct syntax to write a PHP code?
ans) <?php ?>
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.

asked Jun 22, 2022 in PHP by anonymous
edited Jun 29, 2023
the syntax should be <?php ?> why it is <? ?>

Related questions

0 votes
1 answer 1.2k views
0 votes
1 answer 218 views
0 votes
1 answer 232 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

...