Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
structure
code
web development

What is the structure of PHP code?

Educative Answers Team

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

PHP is an embedded scripting language; this means that it is possible to write PHP code into an HTML file. Since web browsers can only process HTML files, the web-server converts and embeds the PHP code into one HTML file before sending it to the browser.

svg viewer

HTML tags

There are HTML tags for PHP code to indicate the start and end of PHP code in an HTML file. Any one of the following 4 tags can be used:

  1. <?php php-code-here ?>
  2. <SCRIPT LANGUAGE="php"> php-code-here </SCRIPT>
  3. <? php-code-here ?>
  4. <% php-code-here %>

The first and second tags are the ones most recommended and most widely used. Using a tag which is rarely used may result in a web-server being unable to detect the start and end of the PHP code.


Commenting

# and // are used to comment out a single line of code, while /* and */ indicate the start and end of a commented block of code.


Code

<?php
print "Hello";
echo " World!\n";
/* Commenting out a block of code
echo 'This line won't execute.\n';
*/
# The last line does not require a semicolon
print "The last line."
?>

RELATED TAGS

php
structure
code
web development
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring