PHP for beginners – Chapter 5

Welcome Back, Now we are going to learn Chapter 5 from PHP for beginners.

In this chapter, we will start coding in PHP. 🙂

We will start from “Hello world” example.

Open any editor. To choose editor – check our post for it. PHP for beginners – Chapter 2

Create a new file test.php

Write following code :

<?php

echo “Hello world!”;

?>

Save this file.

To run this file. first you have to start apache server. I hope you have read our article on this. PHP for beginners – Chapter 3

Start apache server. Place this file into htdocs folder. after starting your apache server.

Open your browser and type http://localhost/test.php

you will see output “Hello world”.

Now, we will see some more example for loops. Suppose we want to print 1 to 10 numbers.

<?php

for($i = 1; $i<=10;$i++) {

echo $i.”<br />”;

}

?>

This output will be :

1

2

3

4

5

6

7

8

9

10

You can learn more about php operators, loops, functions, strings and all from w3schools.com 

I hope this article will help you to start coding in php.

PHP for beginners – Chapter 4

Today we will learn how to write a code in php.

To write a code in php there is predefined syntax.

Whenever you want to start to write code you have to type <?php

then you can write your business logic.

After this to end your php code you have to type ?>

So simple, write your code within

<?php

/*  Your code here */

?>

In next chapter we will learn how to use looping conditions, how to do comments and other things.

 

PHP for beginners – Chapter 3

Here we are going to learn third step towards PHP. PHP for beginners – Chapter 3.

How to run a sample “hello world” code. Is there any server or compiler required for that?

I hope you have read PHP for beginners – Chapter 1 and PHP for beginners – Chapter 2 before reading this Chapter. In this chapter you will know how to run your code.

Once you have written you code. It is very important to run code. To run code, we need to start Apache server. You have to install Wamp or Xampp server for this.

I will explain you this in Xampp server.

Open Xampp Control Panel. You will see as per following image.

Xampp Control Panel

Click on Start button in row of Apache Module. It will start Apache Server. To check it is working proper or not open your browser and type http://localhost

If it will run successful then it will display following page.

This is indicating that you have successfully install xampp control panel. Now you are ready to play with PHP.

 

 

PHP for beginners – Chapter 2

Here we are going to learn second step towards PHP. PHP for beginners – Chapter 2.

How to write a code? Means you need to know about editor in which you can make a code.

To write code in PHP, if you have good editor then you can write code in more speed and efficiently.

There are some free and paid editor available to write code.

Free Editor :

  1. Notepad++
  2. Net Beans
  3. Brackets

Paid Editor :

  1. Dreamweaver
  2. PHPStrom

Here i listed only editors which i know. There are others also available.

I have used above all. I prefer Net Beans which is free. PHPStrom is also very good. But it is paid editor.

Just click on editor you want use and download it from there.

Click here to Start with PHP for beginners – Chapter 3

PHP for beginners – Chapter 1

Here we are going to learn first step towards PHP. PHP for beginners – Chapter 1.

How many software are required?

To make a code in PHP we need to compile or run code. PHP is server side scripting language. So you need apache server to run written  PHP code.

There are two famous software who provide server for PHP.

  1. Wamp Server
  2. Xampp Server

You can download wamp server from here. 

You can download xampp server from here. 

You need mySql server also to communicate with Database.

You will find this in built with these two software.

Just follow simple steps and you are done with software installation to run PHP code.

Click here to Start with PHP for beginners – Chapter 2

 

PHP for beginners – Introducation

Learning any language is easy, if approach to learn language is correct.

You must have knowledge of flow statement (loops – if else,while,for etc.,) , arrays, structures (stack etc., ) to use. They are irrelevant to language.

To lean any language, following thing to you need to know.

  1. How many software are required?
  2. How to write a code? Means you need to know about editor in which you can make a code.
  3. How to run a sample “hello world” code. Is there any server or compiler required for that?
  4. Syntax of the language.
  5. Make a simple examples like printing a lines, use Loops, use arrays, use structures.
  6. One file handling program.
  7. Session management (if exists in language).
  8. Database Connections. (Very important)

If you use this approach to learn any language. You can easily understand the language and learn language.

So we will start with this approach and you will able to built a PHP script by yourself.

Click here to Start with PHP for beginners – Chapter 1