Starting Programming with PHP
Hello Readers!Many friends who want to learn PHP but the problem they face is they don't know how to start and where to start . For a newbie , when there is no one to guide , it is the hardest thing to make and run his first Script . So here I will tell you how to make and run your first basic PHP script.
Some free but good books to learn PHP are
also given at the end of the page ;) .
What is PHP?
PHP is a back-end programming language for website. PHP stands for Hypertext Preprocessor, which gives you a good idea of its core purpose. Its purpose is to process information and produce hypertext (HTML Page) as a result.
PHP is a server side scripting language , which means that PHP scripts need a Web
server to run . There are many web Servers available for free. You can develop and test your PHP scripts locally ( On your machine without internet ) using any server given below 👍Why PHP?
Though there are other back-end languages (e.g ASP , PYTHON etc) but PHP is the most used language on the internet. Most of the websites use PHP for their back-end. WORDPRESS CMS is powering about 26.4% of the web in 2016 . Almost all the themes and plug-ins of wordpress are coded in PHP . You can Develop almost any type of website Using PHP . So Learning PHP is not a bad idea 😉 .
In this post we will cover the following thing
Choosing and Installing a Server
There are many web Servers available . I personally use XAMPP. It is also available with PHP 7 support in its latest release . You can download XAMPP (here) .Some good alternatives to XAMPP are as follows
Following web Servers ( Apache–MySQL–PHP Packages ) are the best alternatives to XAMPP
Configuring Server
This is not actually configuring web server .It is checking web server if working right or not .
So after installing Web server on your machine , start your server from start menu ( on Windows ).
So after installing Web server on your machine , start your server from start menu ( on Windows ).
- Click on Start button next to Apache
- After Clicking on start it will look like this on Xampp ,on other web server will show running
- Now open browser and type localhost or 127.0.0.1 .It will show something like this on Xampp . On other Servers it will show some page or directory listing page ( a page with a "Index of /" heading on the left top corner ) but not your ISP's homepage.
- Select Your language and proceed to next page.
Making Your First PHP Script
- Create a new empty plain text file on your Desktop or in your working directory.
- Open the newly created plain text file with Notepad or any plain text editor.
- Write the following code in your text file as it is.
<?php
echo "<h1>Hello World</h1>";
?>
- Save the File.
- Rename the file to your desired name and change it extension to *.php for example if your file name was first script.txt . Change it to first script.php .
Running Your First PHP Script
- Open the directory in which you have installed your Web Server .
- Locate the folder named " htdocs ". If you can't locate the folder htdocs look for " www " .
- Open the " htdocs / www " and create a folder with name " testing " .
- Copy paste the text file we creted in step 1.
- Open your browser and type localhost/testing in the URL bar.
- You will see the file (first script.php) you created with Notepad on this page .
- Click on this file.
- If Page Shows a heading "Hello world" on this page, Congratulations You have successfully created and tested your first PHP script . Best Of Luck.
If you face any problem, let me know in the comments.


No comments:
Post a Comment