Articles added in Mathematics Lab | Cyber Lab is now open | Astronomy Lab is now open | VLSI Lab is now open | 120 SEO Tips article published | More exciting articles coming soon!

PHP Syntax

  • A statement is an expression which is terminated by a semicolon (;)

  • The closing tag of a block in php implies a ; so a ; is not required for terminating an expression.

  • A php script starts with < ? php tag & ends with ?>

  • Whitespace Insentivity:

  • PHP is whitespace insensitive. This being said a whitespace is necessary to separate two words but PHP is insensitive to the number of Whitespace in between two words.

  • E.g.:
  • Here statement (1) & (2) gives the same result.

  • Case Insensitive:

  • PHP is case insensitive when it comes to user defined functions, keywords and classes. (E.g.echo, if else) However PHP is case sensitive when it comes to variables.

  • E.g.
    This will print:
    sum is 4

    NOTE: Here a php error is not produced as $Sum acts as an unassigned variable.

    Print and Echo Statements:

  • Print can output only one statement whereas echo can output multiple statements.

  • Echo is marginally faster than print because it returns a value 1 if it is successful and 0 if not whereas echo does not return any value.

  • E.g.:

    NOTE: Single line comments can be made in php provided it is preceded by either # or //.
  • Multiline comments can be made by preceding it with /* and ending it with */.

  • CACKLE comment system

    Programming Resources
    Computer Networking Fundamentals Android Application