PHP (Hypertext Preprocessor) is an open source server side scripting language created by Rasmus Lerdorf. It is use to create dynamic interactive websites.
A web page is called dynamic if its content can change when viewed again. This is completely opposite to html pages which are static in nature, i.e., their content is fixed and can't change. An interactive web page is one that can interact with user input. For example a page that allows user to enter keywords in a search form and return output based on the search query.
In order to start coding we need a PHP development environment. PHP runs on a server so we will need a web server. If you are doing dev work on your laptop or desktop then you can install a web server on your computer. There are some free softwares available out there online for both Windows and Mac users.
For Windows check XAMPP.
For Mac check MAMP.
You can also checkout PHP website to learn more about PHP installation.
Next we will need a database to save data. MySQL or MariaDB is a good option.
Click here for MySQL.
Click here for MariaDB.
We can write PHP code in text editors like SublimeText or we can use an IDE (Integrated Development Environment) like Eclipse or NetBeans.
If you are using XAMPP or MAMP then it is important that you put your file inside the htdocs folder. So, for example if your project folder is called myphp and you have a file named hello.php then you have to create your project folder myphp inside the htdocs folder and you have to create hello.php file inside the myphp project folder.
To check output of hello.php file open your browser and type the file url. In most cases the following path will work.
In case XAMPP or MAMP is using a different port then you have to include that in the file path. In the following example the XAMPP is using port number 12345.
When you visit a page of a website that is written in php, your browser (the client) makes a request to the server (backend) where the website is hosted. On receiving the request the server then executes the php code of that page and generates a HTML response which is send back to your browser which is then displayed on your screen.
In the following code we will print "Hello World!".
echo "Hello World!";
Have fun learning :-)
Copyright © 2014 - 2019 DYclassroom. All rights reserved.
rendered in 0.0134 sec