0% found this document useful (0 votes)
27 views

PHP 01

Uploaded by

thakkarparth793
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

PHP 01

Uploaded by

thakkarparth793
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Pending from

https://www.w3schools.com/php/php_supe
rglobals.asp

Chapter 1

Introduction to PHP

What is PHP?

● PHP is an acronym for "PHP: Hypertext Preprocessor"


● PHP is a widely used , open-source, interpreted, and object-oriented
scripting language that can be executed at the server-side.
● PHP is well suited for web development. Therefore, it is used to
develop dynamic and interactive web applications (an application that
executes on the server and generates the dynamic page.)
● PHP is free to download and use
● PHP was created by Rasmus Lerdorf in 1994 but appeared in the
market in 1995.
● PHP 7.4.0 is the latest version of PHP, which was released on 28
November.
● The file extension of PHP is “.php”.
● PHP can be embedded into HTML.

● PHP is faster than other scripting languages, for example, ASP and JSP.

● PHP is simple and easy to learn language.

Some important points need to be noticed about PHP are as followed:

○ PHP stands for Hypertext Preprocessor.

○ PHP is an interpreted language, i.e., there is no need for compilation.

○ PHP is faster than other scripting languages, for example, ASP and JSP.
○ PHP is a server-side scripting language, which is used to manage the
dynamic content of the website.

○ PHP can be embedded into HTML.

○ PHP is an object-oriented language.

○ PHP is an open-source scripting language.

○ PHP is simple and easy to learn language.

Features of PHP
● Open-Source and Free: PHP is firstly open source which means
anyone can use PHP code without any licensing (free of cost). Along
with this one can run PHP on any operating system like Windows,
macOS, Linux, Unix and more.
● PHP Server-Side Scripting: PHP code executes on the server before
sending HTML content to the user’s browser, allowing for the dynamic
generation of web pages and handling user interactions.
● Interpreted language: PHP code is interpreted line by line,
eliminating the need for compilation and simplifying development and
testing processes.
● Database connectivity: PHP integrates seamlessly with various
databases like MySQL, PostgreSQL, ODBC , and Oracle, facilitating
data storage and retrieval for web applications.
● Object-oriented programming (OOP): PHP supports OOP concepts
like classes, objects, inheritance, and polymorphism, enabling better
code organization and modularity.
● Built-in functions: PHP comes with a rich set of built-in functions for
various tasks such as string manipulation, date and time handling, file
handling, and more, reducing the need for external libraries.
● Session management: PHP allows for user session management,
enabling personalized experiences and storing user data across
multiple page visits.
● Security features: While security considerations are essential for any
development language, PHP offers several built-in security features
and best practices to help mitigate vulnerabilities.PHP is a secure
language to develop the website. It consists of multiple layers of
security to prevent threads and malicious attacks.
● Web servers Support: PHP is compatible with almost all local servers
used today like Apache, Netscape, Microsoft IIS, etc.
● Performance: PHP script is executed much faster than those scripts
which are written in other languages such as JSP and ASP. PHP uses its
own memory, so the server workload and loading time is automatically
reduced, which results in faster processing speed and better
performance.
● Familiarity with syntax: PHP has easily understandable syntax.
Programmers are comfortable coding with it.
● Embedded: PHP code can be easily embedded within HTML tags and
script.
● Platform Independent: PHP is available for WINDOWS, MAC, LINUX
& UNIX operating system. A PHP application developed in one OS can
be easily executed in other OS also.
● Error Reporting - PHP has predefined error reporting constants to
generate an error notice or warning at runtime. E.g., E_ERROR,
E_WARNING, E_STRICT, E_PARSE.
● Loosely/Dynamically Typed Language: PHP allows us to use a
variable without declaring its datatype. It will be taken automatically at
the time of execution based on the type of data it contains on its value
● Web servers Support: PHP is compatible with almost all local servers
used today like Apache, Netscape, Microsoft IIS, etc.
● Control:Different programming languages require long script or code,
whereas PHP can do the same work in a few lines of code. It has
maximum control over the websites like you can make changes easily
whenever you want.
● A Helpful PHP Community: It has a large community of developers
who regularly updates documentation, tutorials, online help, and FAQs.
Learning PHP from the communities is one of the significant benefits.

1. free to use / open source


2. interpreted
3. obj oriented support
4. server side execution

5. security
6. error reporting

7. server support
8. database support

9. built in functions
10. familiar syntax

11. Embedded
12. php community

13. performance
14. Control

15. platform independent


16. session management
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
or PDF files. You can also output any text, such as XHTML and XML.

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"

Why PHP?

● PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)


● PHP is compatible with almost all servers used today (Apache, IIS,
etc.)
● PHP supports a wide range of databases
● PHP is free. Download it from the official PHP resource: www.php.net
● PHP is easy to learn and runs efficiently on the server side

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: ⇔

Syntax
<?php

PHP code goes here

?>

Example:

<html>

<head>

<title>PHP Hello World</title>

</head>

<body>

<?php echo "Hello, World! This is PHP code";?>

</body>

</html>

Output:

Hello, World! This is PHP code

Refer:

https://www.google.com/amp/s/www.geeksforgeeks.org/php-introduction/amp/

PHP EVOLUTION

Evolution of PHP Versions


Since its inception, PHP has undergone several major releases, each bringing
significant improvements and new features to the language. Let’s explore the
evolution of PHP versions and understand the key advancements in each iteration.

1. Origins and Early Versions (1994-1997)

1994: It all began in 1993 when Rasmus Lerdorf, a Danish-Canadian


programmer, created a set of Common Gateway Interface (CGI) scripts in C
to manage his personal homepage and he named it "Personal Home Page
Tools" (PHP Tools).

1995: Lerdorf released PHP/FI (Forms Interpreter), which combined PHP


with a simple web templating system. This version allowed users to embed
code within HTML.

PHP 2:

1997: PHP/FI 2.0 was released, introducing a more complex and


feature-rich language. The second version of PHP introduced support for dynamic
web pages ,form handling and database connectivity

PHP 3 (1998)

PHP 3, developed by Andi Gutmans and Zeev Suraski, was a complete


rewrite of the previous versions and was released in June 1998. It
introduced a more powerful and extensible platform, making it suitable for a
wider range of web development tasks. The name was changed to "PHP:
Hypertext Preprocessor." Introduced Support for object-oriented programming,
which greatly enhanced the language’s capabilities and improved modularity.
PHP 4:

Released in May 2000 , It Introduced several new features, including support for
XML, improved database connectivity, and the ability to create web services.PHP 4
came out with the Zend Engine 1.0, offering better performance and new features
like session management.

PHP 5:

PHP 5, released in July 2004, introduced the Zend Engine II, offering enhanced
performance and improved object-oriented programming (OOP) capabilities. It had
Enhanced error handling mechanisms, Improved performance, and memory
management.It introduced Better XML support with SimpleXML and DOM.It
introduced PHP Data Objects (PDO) for database access.

PHP 6 (2005-2010, Abandoned):

PHP 6 was intended to bring native Unicode support, but the project faced
numerous challenges and was ultimately abandoned. Many of its features were
backported to PHP 5.3.

PHP 7:

Released in December 2015 , It introduction of the Zend Engine 3, Addition of


scalar type declarations for function arguments and return values, Introduction of
anonymous classes, and closure improvements.Also Spaceship operator was
introduced here.

PHP 8:

Released in November 2020, Introduce JIT compiler, Addition of union types,


allowing variables and function return types to accept multiple possible types.
Enabling metadata to be attached to classes, methods, and properties.

PHP 8.1 and Beyond


Released in November 2021, PHP 8.1 continued to build on the improvements of
PHP 8, introducing features such as:

● Enums.
● Fibers for better asynchronous programming.
● Readonly properties.

The evolution of PHP versions demonstrates the continuous effort to enhance the
language’s performance, flexibility, and functionality. Each release has introduced
features and improvements to make PHP more robust, secure, and
developer-friendly.
PHP INSTALLATION

https://www.w3schools.com/php/php_install.asp
DataTypes

https://www.geeksforgeeks.org/php-data-types/

Comments

https://www.w3schools.com/php/php_comments.a
sp

https://www.w3schools.com/php/php_comments_
multiline.asp

Variables

https://www.w3schools.com/php/php_variables.as
p

Constants:

https://www.w3schools.com/php/php_constants.as
p

Variables scope
https://www.w3schools.com/php/php_variables_sc
ope.asp

Global keyword
In PHP, the global keyword is used within a function to access a global
variable that is defined outside of the function. By default, variables declared
inside a function are local to that function. To use a global variable within a
function, you must explicitly declare it as global.

You might also like