By TechzQuad
z
PHP Environment
Setup
z Install PHP
To install PHP, we will suggest you to install AMP (Apache, MySQL, PHP)
software stack. It is available for all operating systems. There are many AMP
options available in the market that are given below:
• WAMP for Windows
• LAMP for Linux
• MAMP for Mac
• SAMP for Solaris
• FAMP for FreeBSD
• XAMPP (Cross, Apache, MySQL, PHP, Perl) for Cross Platform: It includes
some other components too such as FileZilla, OpenSSL, Webalizer, Mercury
Mail, etc.
z
How to install XAMPP server on windows
We will learn how to install the XAMPP server on windows
platform step by step. Follow the below steps and install the
XAMPP server on your system.
Step 1: Click on the above link provided to download
the XAMPP server according to your window requirement.
z
z
z
z
z
z
z
z
z
z
To start working with your first php
z
program follow the ff. steps:
Step 1. Go to file where you install your xampp server
In my case, I installed xampp on my D:/ drive. If you install
z xampp by default it will install on drive C:/
Step 2. Now open xampp folder and send the [Link] to
desktop for easy access every time you start working with your php code.
z
Step 3. Open htdocs folder.
Step 4. Create a folder inside htdocs, you can name whatever
z
you want. In my case I created a folder php-oop.
Step 5. Inside the php-oop folder, you can now create
you zfirst php script. Let’s try to create our 1st script.
-create a text file named (hello_world.txt) and rename it to (hello_world.php)
-every file you will be created must be end with (.php) extension. You can also
download text editors like: Notepadd ++, Brackets, sublime, etc. for better coding. In
my case, Im using brackets. But if you don’t have any text editors available you can
use notepad.
z
Step 6. Now let’s create our first php
script.
-open the hello_world.php file and write your first php script.
Generally, a PHP file contains HTML tags and some PHP scripting code. It is very easy to create
a simple PHP example. To do so, create a file and write HTML tags + PHP code and save this file
with .php extension.
z
Your script looks like this:
<!DOCTYPE html>
<html>
<head>
<title>My first PHP script</title>
</head>
<body>
<?php echo "Helo World!"; ?>
</body>
</html>
Step 7. Now to see if your code is working. Open any
z web browser and run your first script.
To run your php scripts you must input the server name followed by your folder name
then your php file name.
On your browser type the following url:
localhost/php-oop/hello_world.php
It works!
z
Note: Don’t forget to run your server before you work on
with your scripts or else it will not work.