B.Tech Students: Apply for Live Programming Internship C, C++, Java, Python ,Web page Designing, PHP PHP Syntax | LiveCodeProgramming

PHP Syntax

PHP (Hypertext Preprocessor) code starts with <?php and ends with ?>. Every PHP statement ends with a semicolon ;.

Example
<?php
  echo "Hello, world!";
?>

Comments in PHP

Comments are used to explain code and are ignored by the PHP engine. You can use:

  • // for single-line comments
  • /* ... */ for multi-line comments
Example
<?php
  // This is a single-line comment
  /*
    This is a
    multi-line comment
  */
  echo "Welcome to PHP!";
?>

Case Sensitivity

Function names are not case-sensitive, but variables are:

Example
<?php
  ECHO "Hello";
  echo "World";
  $msg = "Test";
  echo $Msg; // Error: undefined variable
?>