PHP Syntax

Submitted by: 
Visitors have accessed this post 9673 times.

If you came from other programming languages like c/c++ and or Java, you will not have difficulty understanding PHP syntax as they have the same thing in common.

But unlike c/c++ or Java, PHP script is executed on the server and can be inserted within any HTML code and must start scripting block with <?php and end with ?>.

Below is an example of PHP file:

  1. <html>
  2. <body>
  3. <?php
  4. echo "Hello World";
  5. ?>
  6. </body>
  7. </html>

As you can see the “Hello World” is within the scripting block of <?php and ?>. If you sometimes see a block that starts with <? and end with ?>, this means that the shorthand support is enabled in the server.

But for compatibility, use the standard form (<?php).

At the end of the echo command there is a semicolon (;). This means that it is a separator used to separate its line of code from other line.

As of now this is the basic syntax of PHP. As we go on we will teach you on how to create PHP script one by one.


sir sent me php tutorial book download link

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.