Skip to content

How To Use Php ?

For beginners, sometimes it becomes very tough to get started with php. They get confused how to start scripting in php and what softwares and frameworks they should download in order to create a php enabled page.

Well, to resolve all their dilemma regarding the use of php we have come up with this simple tutorial. Here, you will find everything from what softwares are needed to finally create your first php enabled page.

GET STARTED WITH PHP

You will need the following to get started with php.

  1. Web Server
  2. Web Browser
  3. MySQL Database
  4. Text Editor

(1) Web Server- A web server stores and processes the requests(text, image, scripts, HTML documents etc.) made by the user by converting those requests into web pages. If your web server has a built-in support for php, then you don’t need to download it.

But if your web server doesn’t have a built-in support for php, then you will need a local web server to bring php into use.

For beginners, we will recommend to install XAMPP software package. It is available for free on the official website of Apache Friends. It includes Apache HTTP server, MariaDB(MySQL Database), Php and Perl. So, you are not required to download MySQL database and Php separately as it involves the both.

(2) Web Browser- A web browser is a software which is used to make requests by the user to the web server. These request are identified by a URL(Uniform Resource Locator). Here are some web browser that you may use.

  • Internet Explorer(Default)
  • Google Chrome
  • Mozilla Firefox
  • Safari
  • Opera

(3) MySQL Database- MySQL database is used to store sensible information or data such as username, password etc. of a website or web application. It can be downloaded from the official website of MySQL. It also comes with XAMPP as a built-in tool.

(4) Text Editor- A text editor is a web development tool which is used to edit, create and manage php scripts and files. Some of the best php editors are listed below.

  • For Windows : Notepad++, Adobe Dreamweaver, Codelobster, Sublime Text, Microsoft WebMatrix, Crimson Editor, Kantharos PHP IDE etc.
  • For MacOS : TextMate, Smultron, Coda etc.
  • For Linux : gedit, Kwrite, Kate, KDevelop etc.

CREATING PHP ENABLED PAGE

Now after installing all the essential softwares, you can create your first php enabled page. We have shown below a simple example to create your first php script using the php function echo to print the output on your web page.

PHP Syntax :

<?php
(php script)
?>

Example :

<!DOCTYPE html>
<html>
<body>
<h1>My first page</h1>
<?php
echo “Hello World!!”;
?>
</body>
</html>

Output :

My first page
Hello World!!

GETTING SYSTEM INFORMATION

You can also get the information of the system such as configuration settings, modules, variables, credits, licence, environment, php version etc. by calling phpinfo() function.

Syntax : 

<?php
phpinfo(INFO_ALL);
?>

The above function will display all the information related to php configuration. However if you want to get a particular information, you can use the following parameters instead.

  • INFO_GENERAL
  • INFO_CONFIGURATION
  • INFO_CREDITS
  • INFO_LICENCE
  • INFO_VARIABLE
  • INFO_ENVIRONMENT
  • INFO_MODULES

We have tried to give you the best possible information on how to use to php and its tools. Hope you liked this article. For further updates and related information, stay tuned to ourphp blogs.

Facebook
Twitter
LinkedIn
Pinterest