You are currently viewing PHP beginner tutorials – zero to hero PHP course 2023
PHP tutorial in 2020

PHP beginner tutorials – zero to hero PHP course 2023

Spread the love

PHP beginner tutorials in 2020 | PHP beginner tutorials

PHP beginner tutorials
PHP tutorial in 2020

What is PHP?

PHP beginner tutorials | PHP stands for Hypertext Preprocessor. PHP is a most powerful and widely-used open-source server-side scripting language. PHP scripting language is used to write dynamically generated web pages. PHP scripts are executed on the web servers and the final result is sent to the browser as plain content with the help of HTML tags.
for Hypertext Preprocessor (PHP) is an open-source, interpreted, and object-oriented scripting language that means it is executed at the server-side. It is used to develop web applications these applications are executed at the server-side and generates a dynamic web page.


What is PHP

  • PHP is a server-side scripting language.
  • It is an interpreted language that means there is no need for compilation.
  • Object-oriented language.
  • It is an open-source scripting language.
  • It is simple and easy to learn the language.

PHP can be easily embedded within a normal HTML web page. That means inside your HTML documents you can write PHP statements like this:

    <title>My First PHP Application</title>
// Program to display simple greeting message
echo 'Hello World!';

PHP Features

PHP has many features some of them are listed below:

  • Performance: PHP scripts are executing much faster than those scripts written in other languages such as JSP & ASP.
  • Open Source: PHP is open-source software available on the internet, you can develop your website with all the version of PHP according to your requirement without paying any cost.
  • Platform Independent: PHP are available for WINDOWS, MAC, LINUX & UNIX OS.
  • Compatibility: It is compatible with almost all the local servers available and used today like Apache, IIS etc.
  • Embedded: We can embed PHP code easily within HTML tags and script.

Java logic building programs.

What You Can Do with PHP?

There are unlimited things that you can do with PHP.

  • You can generate dynamic web pages and files.
  • Can create, open, read, write, and close files on the webserver.
  • Collect data using a web form such as user information, email ids, credit card information, and many more.
  • I can send emails to the users of your website.
  • Cookies can send and receive to track the visitor information of your website.
  • Information’s can be the store, delete, and modify in the database.
  • Restrict unauthorized access to your website.
  • Data can be encrypted for safe data transmission over the internet.

Learn how you can encrypt data transmission using SSL

PHP tags always start with <?php and end with ?>

Embedding PHP Scripts

There are four different ways that you can embed your PHP code.

  1. You can embed PHP code into a standard HTML page. To do it you have to put PHP code between <? and ?> tags.



        <title>Simple PHP Code</title>
        <? echo "Hello World, Stay Safe"; ?>


Above mentioned embedding style is the most common way to embed your PHP code.


  1. Another most popular way to embed PHP code is within <?php and ?> tags:
 echo "Hello World, Stay safe"; 

This style is always available and is recommended when your PHP code needs to be portable to many different systems.

  1. Embedding PHP within<script> tags is another style that is always available:
<script language="php" > echo "Hello World";</script>
  1. One final style, in which the code is between <% and %> tags, is disabled by default:
<% echo "Hello World"; %>

Creating a variable in PHP

Variables are the name or some symbols that are used to store values such as numeric values, memory addresses, characters, etc.

Most required Rules for PHP variables:

  • Variables start with $ sign and followed by the name of your variable.
  • A variable must start with an underscore or letter.
  • The variable name cannot start with numbers in PHP.
  • It can only contain alphanumeric and underscore (A-z, 0-9, and _).
  • Variable names are case sensitive.
$sampleVariable = "Hello, this is example variable";
echo "message in variable: $sampleVariable "; 

Decision-making statements:

PHP supports three types of decision-making statements, they are

  1. if..else statement
  2. else if statement
  3. switch statement

Example of if..else statement

echo "$num is even number";  
echo "$num is odd number";  

else if statement

$x = 10;

if ( $x < 0 ) {
  echo "x is negative.";
} elseif ( $x == 0 ) {
  echo "x is equal to 0";
} else {
  echo "x is positive";
echo " value of x = " . $x;
//Output "x is positive" and "value of x = 10".

switch statement

$myfavcolor = "black";
switch ($myfavcolor) {
    case "red":
        echo "Your favorite color is red!";
    case "blue":
        echo "Your favorite color is blue!";
    case "green":
        echo "Your favorite color is green!";
    case "black":
        echo "Your favorite color is black!";

        echo "Your favorite color is neither red, blue, nor green!";

Functions in PHP

  1. In PHP function name always starts with a small letter, underscore (_).
  2. The function name cannot start with numbers.
  3. Never use the predefined constant name, for example, PHP_OS.
  4. Never use reserved keywords like, if, else, etc.
  5. Case insensitive.


function fun_name(){
Blocks of statements;


function displayMsg(){
echo "Hello world, stay safe.";

Now to display the above message we need to call the function in order to print the message.

Syntax calling Function:


Above Program to call the method.

function displayMsg(){
 echo "Hello world, stay safe."; 


Spread the love

Santosh Adhikari

Hello, it's me Santosh Adhikari, from Kathmandu, Nepal. I'm a student of Science and Technology. I love new challenges and want to explore more on Software Quality Assurance. I want to be a professional SQA. I'm also interested in Blogging, SEO activities.
0 0 votes
Article Rating
Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments