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

  • जन्माष्टमी व्रत पूजा विस्तार से | दही हांडी | Krishna Janmashtami Puja
    जन्माष्टमी व्रत पूजा विस्तार से, दही हांडी: Krishna Janmashtami Puja Festival
  • What is Verb
    What is Verb? Types of Verbs and Examples Grammar
  • Chemical Properties of Matter (Element, Compound and Mixture)
    Chemical Properties of Matter examples (Element, Compound and Mixture) Science
  • Draupadi Murmu Biography In Hindi | द्रौपदी मुर्मू की जीवनी
    Draupadi Murmu Biography In Hindi | द्रौपदी मुर्मू की जीवनी Biography
  • MS Dhoni (Mahendra singh Dhoni) Cricket Biography in Hindi
    MS Dhoni (Mahendra singh Dhoni) Cricket Biography in Hindi Biography
  • Newton's laws of Motion, State and Explained, Formula
    Newton’s laws of Motion, State and Explained, Formula Science
  • Kishkindha Kand in Hindi | Ram meets Hanuman | किष्किंधा कांड
    Kishkindha Kand in Hindi | Ram meets Hanuman | किष्किंधा कांड Spiritual
  • Impeachment meaning in Hindi | महाभियोग की परिभाषा और प्रक्रिया
    Impeachment meaning in Hindi | महाभियोग की परिभाषा और प्रक्रिया General Knowledge

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

Waterfall Model in Hindi (Waterfall Model क्या है?) Waterfall Model in Hindi (Waterfall Model क्या है?) Important
Design Pattern in Software Engineering Design Pattern in Software Engineering Important
JSON The Data Interchange Standard Format JSON The Data Interchange Standard Format Important
Difference between Bugs, Errors and Issues in Software Testing Difference between Bugs, Errors and Issues in Software Testing Important
Ration Card and One Nation One Ration Card Scheme Ration Card and One Nation One Ration Card Scheme Important
Difference between Git Merge and Git Rebase | Git Rebase vs Git Merge Difference between Git Merge and Git Rebase | Git Rebase vs Git Merge Differences

Leave a Reply Cancel reply

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

  • National Farmers Day in Hindi | राष्ट्रीय किसान दिवस पर निबंध | चौधरी चरण सिंह जयंती
  • Human rights day in Hindi: 10 दिसंबर ह्यूमन राइट्स डे
  • Unicef day is celebrated on December 11 | Speech on unicef day
  • Indian Navy Day: जल सेना दिवस कब और क्यों मनाया जाता है?
  • P V Sindhu Biography in Hindi, Badminton, State, Caste पी. वी. सिंधु जीवन परिचय, कहानी, राज्य, जाति
  • Draupadi Murmu Biography In Hindi | द्रौपदी मुर्मू की जीवनी
  • Difference between Internet and Intranet
    Difference between Internet and Intranet Differences
  • Difference between TCP and UDP
    Difference between TCP and UDP | TCP vs UDP examples Differences
  • Similarities and difference between OSI and TCP/IP model
    OSI vs TCP/IP Model, Similarities and difference between OSI and TCP/IP model Networking
  • OSI Model | 7 Layers of OSI Model in Computer network
    OSI Model | 7 Layers of OSI Model in Computer network, Functions Networking
  • Network kya hai (नेटवर्क क्या है)
    Network kya hai (नेटवर्क क्या है) Networking
  • IPv4 Vs IPv6 | Difference between IPv4 and IPv6
    IPv4 Vs IPv6 | Difference between IPv4 and IPv6 Differences
  • TCP/IP Model, Full Form, Layers and their Functions
    TCP/IP Model, Full Form, Layers and their Functions Networking
  • 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