Logic Matters Free Video Tutorials

PHP Video Tutorial Part 1 & 2[ PHP Basic Syntax,Comments,Variables,Strings]

1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 5.00 out of 5)
Loading ... Loading ...

Hi friends,

I ‘m starting the PHP video tutorial sequels , hope it will continue …

So dowload my PHP Video tutorial Part 1 and Part 2

Part 1: Documentation [Introduction,History,Features,Installation]

Part 2: Video Avi Format[ PHP Basic Syntax,Comments,Variables,Strings]

Watch PHP Tutorial Part 2.1:

YouTube Preview Image

Watch PHP Tutorial Part 2.2:

YouTube Preview Image

 


Documentation

Hello Friends,

Welcome To PHP Tutorial Part 2

______________________________________________________________________________

So Let’s Start the Tutorial Part 2:

Go to Xampp Control Panel and start the “Apache” and “My Sql”

Now check whether the PHP is installed correctly or not for this Go to any web browser and type “localhost” without quotes.

If there is message like this :

“Congratulation: You have successfully Installed Xampp on this system!”

It means PHP installed correctly.

Now come to the PHP syntax part, here is some different syntax:

a) <?php

?>

b) <?

?>

c) <%php

%>

d) <%

%>

e)<?=

?>

f) <%=

%>

These are all working good, but i recommend you choose a) option its efficient and good one for browsers because all browser support, like c),d),f) all tags are working on asp server like Microsoft , sometime it will not work on other servers so use standard one i.e. a)

Let’s start our first program. The program that I am going to explain is simply giving information about PHP installed on our local server.

Remember always save program with .php extension and run with .php extension also.

If you have xampp installed, then you must save program in htdocs directory to work good otherwise it will show error.

By Default path is “C:\xampp\htdocs”

<?php

phpinfo();  // make sure semicolon at the last of php instruction.

?>

You can make any folder inside htdocs where you save all you program then you path of saving and accessing program is “C:\xampp\htdocs\your_folder_name”

So our first program is:

<?php

phpinfo();  // make sure semicolon at the last of php instruction.

?>

Now save this program at correct path and run the program, let’s suppose I will save in sandbox folder and name of saved program is “my_phpinfo.php” So the address of saved program is : “c:\xampp\htdocs\sandbox\my_phpinfo.php”

Now check the output it will give info all about PHP installed on your local server.

</html>

<head>

<title>Display Data</title>

</head>

<body>

<?php

echo “Hello Guys!”;

?>

</body>

<html>

Now come to the second program if we want to display data on browser, you can embed PHP anywhere in html. And in PHP for display data we use “echo” command.

Here is Program:

<html>

<head>

<title>Display Data</title>

</head>

<body>

<?php

echo “Hello Guys!”;

?>

</body>

Save this program at correct path and run! You output “Hello Guys!” in the browser without quotes.

Hope now you understand how to display the data on browser with simple PHP command.

Now come to Comments Part

There are two types of comments in PHP

a) Single Line comment

b) Multi Line Comment

a) For single line comment the syntax is  //”

e.g.:

<?php

echo “Hello Guys!”;  // This is single line comment :)

?>

b) For multi lien comment the syntax is “/*     */”

e.g.:

<?php

echo “Hello Guys!”; /* This is

Multi line

comment

*/

?>

Variables

There are some simple rules for variable declaration in PHP

  • Variable always start with $ sign
  • Variable must be followed by letter or underscore
  • Variable can contain letters, numbers, dashes, underscores
  • There is no space between the variable, use underscore between two words is good practice.
  • Variable name is case sensitive

Let’s come to the Program:

<html>

<head>

<title>Variables</title>

</head>

<body>

<?php

$var=5; //declare variable start with $ sign

echo $var; // there is no need to put commas around the $var i.e. variable name

?>

</body>

</html>

Save this program and check the output it will simply display “5″

If we want to display a string then simple use this:

<?php

$var=5; //declare variable start with $ sign

echo $var; // there is no need to put commas around the $var i.e. variable name

$var2=”This is variable”;

echo $var2;

?>

Check the output

For displaying in different lines use <br/> tag inside echo


<?php

$var=5; //declare variable start with $ sign

echo $var; // there is no need to put commas around the $var i.e. variable name

echo “<br/>”;

$var2=”This is variable”;

echo $var2;

?>

Now output will be in separate lines.


Hope you understand well! I will make this as simple as possible. So everyone can understand.

Thanks for reading this documentation. 


Thanks,

LM Team

If you like it, then why not share with others and bookmark it :

  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogosphere News
  • email
  • Internetmedia
  • LinkedIn
  • Live
  • MSN Reporter
  • MySpace
  • PDF
  • SphereIt
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz
  • RSS
  • blogmarks