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.
Php code is kept inside <? and ?> tags , howerver we should start php code with this <?Php and ending tag with ?>
PHP codes are case sensitive . Take care that you don't mix lower and upper case syntax.
While linking files or images take care of cases as in many servers file name and its extensions are case sensitive.
What is that echo command inside code block?
How you will print two strings by using single echo command?