PHP Introduction | Learn PHP Tutorial

PHP Introduction | Learn PHP Tutorial

What You Should Already Know

Before you continue you should have a basic understanding of the following:

  • HTML
  • CSS
  • jquery
  • JavaScript

If you want to study these subjects first, find the tutorials on our Home page.

You may like

What is PHP?

PHP is an acronym for “PHP: Hypertext Preprocessor

PHP is a widely-used, open source scripting language

PHP scripts are executed on the server

PHP is free to download and use

PHP is popular language!

It is powerful enough to be at the core of the biggest blogging system on the web

(WordPress)!

It is deep enough to run the largest social network (Facebook)!

It is also easy enough to be a beginner’s first server side language!

 

Common uses of PHP

  • PHP performs system functions, i.e. from files on a system it can create, open,
  • read, write, and close them.
  • PHP can handle forms, i.e. gather data from files, save data to a file, through
  • email you can send data, return data to the user.
  • You add, delete, modify elements within your database through PHP.
  • Access cookies variables and set cookies.
  • Using PHP, you can restrict users to access some pages of your website.
  • It can encrypt data.

PHP Introduction

What is a PHP File?

  • PHP files can contain text, HTML, CSS, JavaScript, and PHP code
  • PHP code is executed on the server, and the result is returned to the browser
  • as plain HTML
  • PHP files have extension “.php”

 

What Can PHP Do?

  • PHP can generate dynamic page content
  • PHP can create, open, read, write, delete, and close files on the server
  • PHP can collect form data
  • PHP can send and receive cookies
  • PHP can add, delete, modify data in your database
  • PHP can be used to control user-access
  • PHP can encrypt data

 

With PHP you are not limited to output HTML. You can output images, PDF files,

and even Flash movies. You can also output any text, such as XHTML and XML.

 

Why PHP?

 

What’s new in PHP 7

  • PHP 7 is much faster than the previous popular stable release (PHP 5.6)
  • PHP 7 has improved Error Handling
  • PHP 7 supports stricter Type Declarations for function arguments
  • PHP 7 supports new operators (like the spaceship operator: <=>)

 

“Hello World” Script in PHP

To get a feel for PHP, first start with simple PHP scripts. Since “Hello, World!” is an essential

 example, first we will create a friendly little “Hello, World!” script.

As mentioned earlier, PHP is embedded in HTML. That means that in amongst your

normal HTML (or XHTML if you’re cutting-edge) you’ll have PHP statements like this −

Example:

<html>

   <head>

      <title>Hello World</title>

  </head>

   <body>

      <?php echo "Hello, World!";?>

   </body>

</html>

Output:

Hello, World!

If you examine the HTML output of the above example, you’ll notice that the PHP code is not present in the file sent from the server to your Web browser. All of the PHP present in the Web page is processed and stripped from the page; the only thing returned to the client from the Web server is pure HTML output.

All PHP code must be included inside one of the three special markup tags ATE are recognised by the PHP Parser.

Example:

<?php PHP code goes here ?>

<?    PHP code goes here ?>

<script language = "php"> PHP code goes here </script>

Output:

Hello, World!

 

A most common tag is the <?php…?> and we will also use the same tag in our tutorial.

From the next chapter we will start with PHP Environment Setup on your machine and then we will

 dig out almost all concepts related to PHP to make you comfortable with the PHP language.

You may like for PHP Introduction

Scroll to Top