PHP SYNTAX

Sujitha

PHP Syntax:

      PHP( Hypertext Preprocessor ) is a server side scripting language used for web development. It has a syntax similar to C, Java and Perl.  
      To use proper PHP opening tag '<?php' and closing tag'?>' to enclose your PHP with HTML document.

Here's a brief overview of some common php syntax elements.
  1.  Variable: Start with a dollar sign($) Example: $name="suji";
  2. Comments:  single line command begin with '//' and multi line commands use '/* */'.
  3. Printing/output: To display content use 'echo' and        ' print'.
  4. Strings: Enclosed in single (' ') or double (" ")quotes. Example: $message='Hellow';.
  5. Conditional statement : Use ' if', 'else' and 'elseif' on execute code based on conditional.
  6. Loop: Common loop are ' for', 'while' and 'foreach'.
  7. Function : Defined using function keyword followed by the function name Example: function add ($x $y) {  retuen $x + $y }
  8. Array: Declared using array() or short syntax [] in recent  various. Example: $numbers[1,2 3];.
  9. Superglobal: Pre- define variable accessible any where to the script. Example:$_GET, $_POSY, $_SESSION.
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send