Skip to content
  • Facebook
GeekCer Logo

GeekCer

The geek's Coding education and Review centre

  • Home
  • Tutorials
    • Java
    • Servlet
    • JSP
    • Python
    • C Tutorial
    • Spring
    • Spring Boot
    • MongoDB
    • Hibernate
    • Data Structure
  • General Knowledge
  • Biography
  • Grammar
  • Festival (त्योहार)
  • Interview
  • Differences
  • Important
  • Toggle search form

Home » Important » PHP Tutorial for Beginners in One Page

  • Maven Tutorial
    Maven Tutorial Important
  • Jhansi Ki Rani Lakshmi Bai History, Story, Information in Hindi
    Jhansi Ki Rani Lakshmi Bai History, Story, Information in Hindi Biography
  • Steps to Create a Servlet
    Steps to Create a Servlet Servlet
  • ACID Properties in Hindi? ACID Properties क्या है?
    ACID Properties in Hindi? ACID Properties क्या है? Important
  • Difference between Jenkins and TeamCity
    Difference between Jenkins and TeamCity, Maven, Octopus Differences
  • Exception Handling in Java
    Exception Handling in Java Java
  • National Doctors Day in India and Other Countries, July 1, 2022
    National Doctors Day in India and Other Countries, July 1, 2022 General Knowledge
  • Linear search algorithm | Linear search program in C, Example
    Linear search algorithm | Linear search program in C, Example Data Structure

PHP Tutorial for Beginners in One Page

Posted on October 31, 2021November 13, 2021 By GeekCer Education No Comments on PHP Tutorial for Beginners in One Page
PHP Tutorial for Beginners in One Page

The PHP Tutorial for Beginners in One Page article is for programmers who wish to learn the fundamentals of PHP programming.

PHP is a programming language that runs on the server. When we request a PHP page from our browser, the server computer executes it. It does not run on our computer. Finally, the result is generated in HTML format.

What is PHP? PHP is a server side scripting language. Multiple databases are supported by PHP (MySQL, Informix, Solid, Oracle, Sybase, Generic ODBC etc.).

PHP is a loosely typed programming language.

Table of Contents

  • What are the usage of PHP?
  • Why use PHP?
  • What do we need to run PHP?
  • PHP Syntax
  • How to write comments in PHP?
    • 1) Single Line comment in PHP
    • 2) Multiline comment in PHP
  • How do I write first PHP program?
  • Things to Remember for PHP
  • Variable in PHP?
    • Rules for declaring variables in PHP?
    • How variables are declared in PHP give example?
    • Scope of Variables in PHP
      • Local Scope of variables in PHP
      • Global Scope of variables in PHP
      • Global Scope of variables in PHP

What are the usage of PHP?

PHP may be used for a variety of purposes. We’ve listed a few of the most significant goals below.

  1. Using PHP, we can generate dynamic page content.
  2. PHP allows us to create, open, read, write, remove, and close files on the server.
  3. It can be used to collect data from HTML forms.
  4. PHP has the ability to insert, remove, and alter data in our database.
  5. Some pages on our website might be restricted by PHP.

Why use PHP?

  • PHP may be used on a variety of systems (Windows, Linux, Unix etc.).
  • PHP is a server-side scripting language that can run on practically any platform (Apache, IIS etc.).
  • Powerful, robust, and scalable (When numerous users use the system at the same time, it takes the minimum amount of time possible).
  • It’s free and open source.

What do we need to run PHP?

  • The most important thing is that we require a web server.
  • The PHP engine (Interpreter).
  • A database, preferably MySql, is required.

PHP Syntax

A PHP programming block is always preceded by the characters <?php and followed by the characters ?>. In the document, a PHP programming block can be put anywhere.

                  <?php
  // Code goes here…
?>
                  

How to write comments in PHP?

PHP accepts comments in the ‘C’, ‘C++’, and Unix shell formats.

1) Single Line comment in PHP

                  //.........................
#..........................

2) Multiline comment in PHP

                  /*.........................
..........................*/

How do I write first PHP program?

                  <html>
<body>                 

<?php
  echo "Hello world";
?>
</body>
</html>

Things to Remember for PHP

  • Every PHP statement must be enclosed by the tags <?php and?>.
  • Each command must be followed by a semicolon (;).
  • Variables and constants in PHP are case sensitive, while keywords like echo, if-else, and for are not.

Variable in PHP?

Text, strings, integers, and arrays are all stored in variables. When you declare a variable, you may use it again and again in your script. In PHP, all variables begin with the $ symbol.

Rules for declaring variables in PHP?

PHP have a rule to declare variables which you have to follow. This is very basic of php programming.

  • The $ symbol precedes the variable name, which is then followed by the name of the variable.
  • There is no command in PHP for declaring variables. When we initially assign a value to a variable, it is called a variable.
  • A variable’s name must start with a letter or an underscore.
  • Only alphanumeric letters and underscores (A-Z, a-z, 0-9, and _) are allowed in variable names.
  • There should be no spaces in the name of a variable.
  • Case matters when naming variables ($y and $Y are two separate variables).

How variables are declared in PHP give example?

                  $x=5;
$y=6;
$z=$x + $y;

Scope of Variables in PHP

The term scope refers to a variable’s accessibility, or its ability to be accessible from anywhere in our script. There are three scopes in PHP.

  • Local Scope
  • Global Scope
  • Static Scope

Local Scope of variables in PHP

A variable declared within a PHP function is local, meaning it can only be accessed by the function itself.

                  <?php             
function show()  // Function definition
{
  $x = 5;
  echo $x;
}
show();				// Function calling
?>

Global Scope of variables in PHP

Global variables are those defined outside of the block. They may be accessible from anywhere in our script besides the function’s body.

For example, x has been defined as global in the code below, but it can only be accessible from the global area, not from the body of the function display.

                  <?php  
$x = 5;           
function show()  
{
  echo $x;   // This line will given error;
}
show();				
echo $x; //  Correct 
?>

Global Scope of variables in PHP

Variables defined with the static keyword are kept by PHP even after the function execution is over, and their prior values can be restored.

                  <?php             
function show() 
{
  static $x = 5;
  echo $x;
  $x++;
}
show();
show();
show();
?>

Click here to learn Java Tutorial.

In conclusion, The article “PHP Tutorial for Beginners on One Page” is designed for the developers who want to learn PHP basic and advance. This page will be updated on a regular basis.

I hope you like the PHP Tutorial. Please email us at geekcer.code@gmail.com if you have any questions or concerns.

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • More
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Also Read

Important Tags:PHP, Software Development, Software Engineering, Variables, Web Application

Post navigation

Previous Post: What is International Monetary Fund (I.M.F.)?
Next Post: How to become a Chief Financial Officer (CFO)?

More Related Articles

Difference between Bugs, Errors and Issues in Software Testing Difference between Bugs, Errors and Issues in Software Testing Important
What is Mutual Fund? What is Mutual Fund? Important
Design Pattern in Software Engineering Design Pattern in Software Engineering Important
Ration Card and One Nation One Ration Card Scheme Ration Card and One Nation One Ration Card Scheme Important
Java 8 interview questions and answers, Java Stream, Optional Java 8 interview questions and answers, Java Stream, Optional Important
Visual Paradigm Online and integration with Visual Studio Visual Paradigm Online and integration with Visual Studio Important

Related Posts

  • Difference between Bugs, Errors and Issues in Software Testing
    Difference between Bugs, Errors and Issues in Software Testing Important
  • What is Mutual Fund?
    What is Mutual Fund? Important
  • Design Pattern in Software Engineering
    Design Pattern in Software Engineering Important
  • Ration Card and One Nation One Ration Card Scheme
    Ration Card and One Nation One Ration Card Scheme Important
  • Java 8 interview questions and answers, Java Stream, Optional
    Java 8 interview questions and answers, Java Stream, Optional Important
  • Visual Paradigm Online and integration with Visual Studio
    Visual Paradigm Online and integration with Visual Studio Important

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • National Doctors Day in India and Other Countries, July 1, 2022
  • America Independence Day : 4th July USA | USA Birthday
  • Ganesh Chaturthi Puja in Hindi | गणेश चतुर्थी का व्रत, महत्व, कथा
  • जन्माष्टमी व्रत पूजा विस्तार से | दही हांडी | Krishna Janmashtami Puja
  • Jagannath Rath Yatra History in Hindi | जगन्नाथ पुरी की कहानी
  • Prithviraj Chauhan Biography in Hindi | पृथ्वीराज चौहान जीवनी हिंदी
  • Internal Working of HashMap in Java, Rehashing, Collision
  • MS Dhoni (Mahendra singh Dhoni) Cricket Biography in Hindi
  • Maven Tutorial
    Maven Tutorial Important
  • Jhansi Ki Rani Lakshmi Bai History, Story, Information in Hindi
    Jhansi Ki Rani Lakshmi Bai History, Story, Information in Hindi Biography
  • Steps to Create a Servlet
    Steps to Create a Servlet Servlet
  • ACID Properties in Hindi? ACID Properties क्या है?
    ACID Properties in Hindi? ACID Properties क्या है? Important
  • Difference between Jenkins and TeamCity
    Difference between Jenkins and TeamCity, Maven, Octopus Differences
  • Exception Handling in Java
    Exception Handling in Java Java
  • National Doctors Day in India and Other Countries, July 1, 2022
    National Doctors Day in India and Other Countries, July 1, 2022 General Knowledge
  • Linear search algorithm | Linear search program in C, Example
    Linear search algorithm | Linear search program in C, Example Data Structure
  • Java Tutorial
  • Servlet Tutorial
  • JSP Tutorial
  • Maven Tutorial
  • HTML Tutorial
  • Programs
  • Hindi/English Grammar
  • Difference Between ... and ...
  • HR Interview
  • Important Articles

Write to Us:
geekcer.code@gmail.com

  • About Us
  • Privacy and Policy
  • Disclaimer
  • Contact Us
  • Sitemap

Copyright © GeekCer 2022 All Rights reserved