Installation and first PHP script for beginners

PHP web server database and Operating system

To work with PHP we need a web server. One of the popular web server is Apache. If you are working in windows then IIS is another option you may consider for web server. However Apache works well in windows system.

Database

MySQL or MariaDB can be your choice here. PHP can easily integrate with both the databases.

Integrating all

If we install one by one these products then we need to integrate them all by working in all individual settings . To avoid all these integration process we can select any one of these two packages.

Beginners guide to Installation of XAMPP with Apache PHP MariaDB for learning PHP

XAMPP or WAMP

WAMP : Windows Apache MySQL PHP
XAMPP : Any Operating system ( X ) , Apache, MariaDB , PHP , Perl

If you are in Windows system then work with WAMP server. XAMPP can be used in any platform.

Using these servers we need not have to integrate our individual systems to get full benefit.

Install any one of these servers in your local system and use it as a development platform before deploying in any production system.

Sample Scripts

Here are some php scripts for beginners to try and practice some simple codes to learn the login and program flow. If you have prior experience of any other programs like C, C++ etc then you can easily understand the program flow and the syntax.

In PHP like any other language there are loops, conditions, functions to manage the script. We will be using these functions or syntax to get our desired output.

First PHP script

Let us start with our first PHP code. Copy the file below to notepad or any other editor and save at root of your localhost or web site as test.php . Then open this page in your server.

Localhost

Our code is in our local machine so the physical path for it in windows system using XAMPP server is here.
 c:/xampp/htdocs/test/first.php
In our browser open this address
 localhost/test/first.php
If you have created the file first.php inside htdocs then address is here.
 localhos/first.php
The code inside test.php is here.
<html>
<head>
<title>The first PHP code Hello world</title>
<META NAME="DESCRIPTION" CONTENT="Demo of first PHP code Hello world ">
<META NAME="KEYWORDS" CONTENT="PHP code, sample code, demo PHP"> 
</head>

<body>

<?Php
echo "Hello World";
?>

</body>
</html>


You should get Hello World

First PHP page for Hello world output and checking installation with phpinfo() and uses of comments


PHP codes are case sensitive . Take care that you don't mix lower and upper case syntax.

Every script has two parts, one is about the requirement and the other part is abut the solution. Visitors are requested to first try on their own without visiting the second part for the solution.

Printing all the numbers between 1 to 50
Printing all the even numbers between 1 to 50

Introduction to PHP Printing output by ECHO command

Subscribe to our YouTube Channel here

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    swe

    26-12-2008

    this tutorial is very good.........
    bharathikannan

    12-02-2009

    i am the beginners of php.
    Jaya Devan T

    21-07-2009

    Its good!!!
    Yoni

    30-01-2010

    Informative for begginer
    govinda

    26-01-2014

    good tutorials

    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer