PHP is a server side scripting language that is used to make a web application dynamic.

In today’s PHP tutorial, we will tell you that What is PHP? In this, we will tell about the basic of PHP, which will be useful for both beginner and professional. Today PHP language has become a very popular scripting language because it is an open source language that anyone can easily edit its code and it is absolutely free available.

The full form of PHP is slightly recursive. Full form of php Hypertext preprocessor But in the beginning its full form “Personal Home Page” Used to be

What is PHP ? Php tutorial

Full form of php “Hypertext Preprocessor” Before this happens its full form “Personal Home Page” Was This is a server side scripting language designed for web development. Server side means that it will execute in the server and not execute in the client’s browser. PHP requires a server to execute.

This is the most commonly used open source general purpose scripting language. Open source means that it is absolutely free and its codes are easily available to any user, which any knowledgeable person (knowledgeable person) can change. It can be easily embed in HTML.

Scripting language programming language There is a part of it in which many code series (line by line) are written inside a file which is executed without being compiled. To execute without being compiled means that here only the source code is converted into machine code by the interpreter.

What is called being compile? Compile means that when the source code (user written code) will be converted to machine code then before that the source code is converted into an intermediate (medium) code by the compiler and later converted to the source code by the interpreter. Whenever you Java, C, Compile and execute the code of C ++, then an object file is created which byte code or intermediate code It happens. The intermediate code is given a different name in each programming language. While PHP does not create any intermediate code because it is not compile.

This in 1994 Rasmus Lerdorf But was released for the first time in front of the user in 1995.

What is required to execute PHP code?

Almost everyone uses local computer while working in development mode or while learning PHP. Apache server is required to execute PHP in local machine or server because PHP is executed on server itself due to server side scripting language.

Some software and tools are required to execute PHP code which are of the following types:

  • PHP Parser: It is a tool that converts source code (human-readable code) into machine code (computer-readable code).
  • Web server: To execute PHP generally Apache or Nginx Web server is required but nowadays PHP code IIS server I execute as well, but before that we IIS server I have to do some configuration setting.
  • Web browser: We need a web browser to see the output of PHP.

If you are executing the PHP code in the local computer, then you install a simple package named XAMPP In which Apache server, MySQL, PHP parser is present.

Why should we use PHP?

There is some reason behind using every programming and scripting language. Each language helps in creating different types of applications. Whenever a beginner wants to learn a programming language for a job, he gets confused about which programming language to learn. In which most of the people learn PHP, the main reason is as follows:

  • This is open source general purpose scripting language which is absolutely free.
  • This is loosely cast scripting language, meaning that we do not need to define the data type, due to which it becomes very easy.
  • It is faster than some other scripting language such as JSP (Java Server Page), ASP (Active Server Page)
  • Due to it being free, codes related to every type of project are found free on the internet, which makes it easy to take help or learn something.
  • Most of the PHP tutorials are available on the internet for learning PHP.
  • It is supported by all operating systems such as Linux, Windows, Mac-OS
  • Most of the hosting company supports PHP by default whereas ASP and JSP are not supported by all hosting servers.
  • Its hosting servers are very cheap, due to which it is easy to host the website with the purpose of learning.
  • It can use almost all types of databases such as MySQL, PostgreSQL, Oracle, ODBC, Mongo-Db, etc.
  • In this, new features are updated daily, due to which the security features are also high.
  • There are many frameworks available to develop the application.

PHP Hello World Simple Program

Let us now see a simple program of PHP in which screen Hello World will print. Whenever a new programmer learns programming, he either prints his name or prints Hello World.

<?php 
echo "Hello Word";
?>

This is pure PHP program as no HTML is embeded in it. In this, first I have written PHP syntax and then a print statement that works to print Hello World and then finally close PHP syntax. There is no need to close PHP’s syntax in the Pure PHP program.

PHP syntax less than and question mark (<?) With PHP<? php“Is started by writing and its closing question mark and greater than (?>). for example <? php …………………… ..?> It is not case sensitive, meaning that you can write it both in lower case and upper case but it is suggested to write it in lower case only.

Variables in PHP are case sensitive, meaning if you are defining any variable in lower case then it has to be written everywhere in lower case that means use in lower case itself and if writing in upper case then Use in upper case only. like: $ age = 50; And $ AGE = 40; These are two different variables.

Function name is not case sensitive means if you sum () If you are defining a function of the name, then you can call it by both upper case and lower case like sum (); SUM (); Both of these sum () {} will call the definition of function.

If more than one line writes to a PHP syntax then you semicolon (;) It is important to give it breaks the line and tells the interpreter that a new line is starting from here. But if you write the same line in a PHP syntax, you do not need to give semicolon. like:

single line without semicolon

<?php
echo "Hello Users"
?>

The code written above is correct because it is executing only one line which is written in a PHP syntax but the code given below is incorrect as it has two lines executing in the same PHP syntax.

<?php
echo "Hello Users"
echo "Guptatreepoint Tutorial"
?>

Both the codes given below are correct as semicolon is used in it. And different PHP syntax is written in one.

<?php
echo "Hello Users";
echo "Guptatreepoint Tutorial";
?>
<?php
echo "Hello Users"
?>
<?php
echo "Guptatreepoint Tutorial"
?>

Hello World program with HTML

Like I said above, PHP can be embed in HTML code very easily, but for this you will have to keep the file extension PHP.

<!DOCTYPE html>
<html>
<head>
	<title>Hello World Program with HTML</title>
</head>
<body>
	<h1><?php echo "Hello World!"; ?></h1>
</body>
</html>

What to learn before learning PHP?

When people learn PHP tutorial, before that there is a question in everyone’s mind that what should be learned before that. You should have basic knowledge of these three things before learning PHP tutorial.

  1. HTML
  2. CSS
  3. JavaScript