HTML Online Tutorial Contents

Following are the posts for HTML online Tutorial. To learn everything about HTML, just read these posts: HTML Online Tutorial HTML TAGS (2) HTML BASICS (3) HTML ELEMENTS (4) HTML ATTRIBUTES (5) More »

XHTML

XHTML stands for Extensible Hypertext Markup Language. It is also known as XML (Extensible Markup Language). It is a markup language. In XHTML, there are no predefined tags. The user defines the More »

HTML SUMMARY

In this tutorial, you learned: HTML Introduction HTML Tags HTML Basics HTML Elements HTML Attributes HTML Paragraphs HTML Headings HTML Formats HTML Image HTML Links HTML Lists HTML Frames HTML Table After More »

HTML TABLES (13)

HTML Tables are used to arrange data in web pages. HTML allows the use of tables by <table>…</table> tags. Each row in HTML table is recognized by <tr>…</tr> tag. In each row More »

HTML FRAMES (12.2)

Nested frames example: For the following example to work, there are two other simple HTML files : “HMTL11e1 frame a.html” and “HMTL11e1 frame b.html”. your browser will divide your screeub half. The More »

 

Tag Archives: PHP

Learn about the syntax of PHP with examples

Learn about the syntax of PHP with examples

To learn every programming language it is necessary to understand its syntax. For PHP we will start from LEXICAL STRUCTURE which is basically the lowest level of syntax for PHP. Lexical structure defines how we name the variables, the characters we can use or how we can insert comments in the program etc.

PHP is case sensitive and insensitive: The variables which can be defined in PHP are case sensitive. But the names of user defined functions and classes are case in-sensitive in PHP. Moreover the keywords and constructs which are build in PHP are case insensitive as well. An example of keyword is echo:

echo(“My blog is website-school “);

Echo(“My blog is website-school “);

eCho(“My blog is website-school “);

All of the above statements are same.

Since we know that PHP code is executed on server. As a result the plain HTML is sent back to the browser.

PHP Scripting Block:

The php block will always start with .  But if the server supports the shorthand then the php block will start from . The position of PHP block can be anywhere in the document. Since you want your document to provide as much as compatibility as possible so you should use the:

php

?>

syntax to write the php block.

PHP Statements:

The collection of PHP code that does something is known as PHP statement. For you,  easiest example of PHP statement could be variable assignment such as:

$website = 50;

$demon = 2;

you should note that variable is basically a changing value. You can declare a variable name and type once and can change its value at any point in the program and as many time as you want. In the above statement the website is the variable that you will declare in php and assign it a value of 50. You really need to remember that variable name in PHP starts with $ sign! Similarly, the demon variable has been given a value of 2.

$school = “blog”;

If you look at the above statement then you will notice that the variable school does not have numerical value, instead it has been assigned a word “blog” as a value. You need to remember that the words (or group of words i.e. complete sentences as well) are written inside quotation marks while assigning them to a variable.

Similarly, the complicated example of PHP statement can be loop that has multiple checks or exit points such as:

if ($website==$demon)

{

echo “both variables are equal”;

echo “YAHOO”;

}

The above example is a if else loop which will be explained in a loop section in detail. But for now all you need to know is that this loops checks if the value of website and demon are equal. If yes than the output of loop will be a statement:

both variables are equal YAHOO

For now you don’t have to worry about LOOPS. We will get there Learn about the syntax of PHP with examples

Since we are discussing PHP statements, so I want to mention Compound statements. The statements which are enclosed in braces are basically known as Compound statement. Like the echo statements in the above loop are compound statements.

I know that those of you who know nothing about programming are wondering what is the purpose of semicolon? First I want to introduce you to comments in PHP code.

PHP Comments:

The comments about the code can be written after each statement by putting // after the end of every statement. You can either do that or you can put your comments between /* comment*/ to insert a large block of comments in the code.

Now we will move on to semicolon!

PHP Semicolon:

The semicolon in PHP statements is used to separate the single statements. It also act as a separator from one group of statements to another set of statements. The compound statements do not require the semicolon after a closing brace of any loop or conditional test. But in the single compound statement the semicolon is must. For example, if you see this example again:

if ($website==$demon)

{

echo “both variables are equal”;     // semicolon is compulsory here.

echo “YAHOO”;    // semicolon is compulsory here.

}  // semicolon is not required here.

Now I think that you can easily recognize the comments after each statement. If you are writing a PHP code, then you can easily skip the semicolon after the PHP tag because using a semicolon after a PHP tag is optional.

php

if ($website==$demon)

{

echo “hi”;

}

echo “YAHOO”    //semicolon is optional after this tag

?>

But for good programming practice, You need to remember that semicolon are must at the end of every single statement, they are not use at the end of compound statement end brace and they are optional after PHP tag. But you should put them after PHP tag so that you don’t get confused.

To get a mobile app for your business visit www.codescamp.com

Book a free consultation today!

Learn about PHP and MySQL

Learn about PHP and MySQL relationship

PHP Introduction

PHP is basically a language which creates HTML content. Before starting this tutorial, you should have basic understanding of: HTML / XHTML, JavaScript. You can find the tutorial for HMTL here:

HTML online Tutorial Contents

 

We recommend that the reader should go through these tutorials first before PHP tutorial.

PHP stands for Hypertext Preprocessor. PHP can be used in three ways: Server side Scripting, Command Line scripting and Client-side GUI (Graphic User Interface) application. There are many databases which are supported by PHP e.g. MySQL, Solid, Informix , Sybase etc.). PHP is a free to download and use. Also, it is and open source software. PHP runs on various platforms like Windows, Unix and Linux etc. It runs efficiently on server side and is easy to learn. Following is the brief introduction of the ways in which PHP is used:

Server Side Scripting:

PHP is a server side scripting programming language like ASP. PHP is basically designed and best suited to create web content. PHP parser and a web server is used to generate the HTML. The web server is used to send the coded documents. PHP can also be used to generate the XHTML documents, graphics, animations, pdf files, etc.

Command Line Scripting:

The command line can be used to run PHP scripts like Perl, Unix Shell, or awk. These command line scripts can be used for various administration tasks of a system like log parsing or backup.

Client-Side GUI Application:

The cross platform GUI applications can be written by using PHP-GTK.

PHP File:

PHP files are capable of containing text, HTML, scripts and various tags etc. The extension of any PHP file is “.php”, “.php3” and “.phtml”. These files return to the internet browser as a plain HTML.

PHP and MySQL:

The database server is known as MySQL. It supports standard SQL. It is available freely to download and use. It is usually used for both small and large applications. It can compile various platforms.

If you need to develop a cross platform application i.e. develop it on Windows and serve on Linux then you can use PHP and MySQL together.

PHP Hypertext Preprocessor

PHP stands for Hypertext Preprocessor. It is another general purpose scripting language. It is designed to make dynamic web pages. The procedure is same like ASP. The user sends request in PHP code embedded in HTML to the web server. Then the web server processes the request and generates HTML code as an output. This HTML code is then interpreted by user browser to display the result.

ADVANTAGES OF PHP:

Following are the advantages of PHP:

  • PHP has variety of built in base functions and other via extensions.
  • PHP has syntax similar to other high level languages e.g. C language.
  • PHP mainly focuses on server side scripting.
  • PHP is similar to other server side scripting languages.

There is more information about PHP coming up on this site very soon.