Sharp Tutorial
Sytanx and Rule in PHP

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

PHP Introduction

  • PHP home
  • PHP introduction
  • How to install and run
  • Syntax and Rule in PHP
  • Data type and operator
  • If else in php
  • Loop in php
  • Array in php
  • Sring in php
  • Function in php
  • Include in php

Working with Forms

  • Get and Post
  • Get Form input into PHP
  • Form Validation

PHP with MySQl

  • Connect PHP & Mysql
  • Insert using PHP Mysql
  • Select using PHP MySql
  • Delete Update using PHP Mysql
  • Login Page Example in PHP

Advanced PHP

  • Session in PHP
  • Cookies in PHP
  • File Handling in PHP
  • File Upload/Download PH

Object Oriented PHP

  • Class Obejct in PHP
  • Constructor in PHP
  • Destructor in PHP
  • Inheritance in PHP

PHP Syntax

PHP code starts with <?php  and ends with  ?> inside these tags php code is written. PHP statements are terminated with semicolon(;) except some statements like if else loop etc.

In PHP the commands are not case sensite while the variables names are case senisitve . 

echo “Hello Php”;  or ECHO ” Hi PHP” ;  both statements are ok.

but $name;  $NAME;  $Name ; are different variables.

PHP scripts may be written number of types in a php page . But start and end should be proper. 

Example of Multiple times php code in a page.

 <html>
<body bgcolor="cyan">
<center>
HTML Content First Block
<br>
<?php
echo " First block of PHP code";
?>
<br>
HTML content Second Block <br>
<?php
echo" Second block of PHP Code";
?>
</center>
</body>
</html>

In above example there are two blocks of normal html and two php script block and output is as following.

HTML tag in PHP code

HTML tags may be embedded in php scripting code. Those tags are written in echo command as following example.

 <html>
<body bgcolor="cyan">
<center>
HTML Content First Block
<br>
<?php
echo "<b> This block is bold because of <b> tag. </b>";
?>
</center>
</body>
</html>

Comment in PHP

In PHP commenting of the code is very simple. Single line comment is // 

multiline comment is /*           */ as in folllowing example and .(dot) is used to concatenate the values.

 <html>
<body bgcolor="cyan">
<center>
HTML Content First Block
<br>
<?php
echo" only this line is being printed";
// echo" this line is not printed commented as single line
/* mulitline comment
these lines is out of executions
because of the multiline comment
--end here */
$FirstName="Rahul";
$LastName="Taneja";
// We can concatenate those values as following.
echo"<br>$FirstName" ." $LastName";
?>
</center>
</body>
</html>

Output of the above program is shown in following image.

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial