Vous êtes sur la page 1sur 8

1. What is PHP?

PHP is a server-side scripting language. that is used to develop Static websites or


Dynamic websites or Web applications.

PHP means - Personal Home Page, but it now stands for the recursive backronym
PHP: Hypertext Preprocessor.

PHP scripts can only be interpreted on a server that has PHP installed.

PHP code may be embedded into HTML code, or it can be used in combination with
various web template systems, web content management system and web frameworks.
PHP scripts can only be interpreted on a server that has PHP installed.

The client computers accessing the PHP scripts require a web browser only.

A PHP file contains PHP tags and ends with the extension ".php".

PHP Syntax:

A PHP file can also contain tags such as HTML and client-side scripts such as
JavaScript.

 HTML is an added advantage when learning PHP Language. You can even learn
PHP without knowing HTML, but it’s recommended you at least know the basics
of HTML.

 Database management systems DBMS for database powered applications.

 For more advanced topics such as interactive applications and web services, you
will need JavaScript and XML.

Uses of PHP:

There are three main areas where PHP scripts are used:

 Server-side scripting. This is the most traditional and main target field for PHP.
You need three things to make this work: the PHP parser (CGI or server module),
a web server and a web browser. You need to run the web server, with a
connected PHP installation. You can access the PHP program output with a web
browser, viewing the PHP page through the server. All these can run on your
home machine if you are just experimenting with PHP programming. See the
installation instructions section for more information.

 Command line scripting. You can make a PHP script to run it without any server
or browser. You only need the PHP parser to use it this way. This type of usage is
ideal for scripts regularly executed using cron (on *nix or Linux) or Task
Scheduler (on Windows). These scripts can also be used for simple text
processing tasks. See the section about Command line usage of PHP for more
information.

 Writing desktop applications. PHP is probably not the very best language to
create a desktop application with a graphical user interface, but if you know PHP
very well, and would like to use some advanced PHP features in your client-side
applications you can also use PHP-GTK to write such programs. You also have
the ability to write cross-platform applications this way. PHP-GTK is an extension
to PHP, not available in the main distribution. If you are interested in PHP-GTK,
visit » its own website.

2. PHP History
PHP development began in 1994 when the Danish/Greenlandic/Canadian
programmer Rasmus Lerdorf initially created a set of Perl scripts he called “Personal
Home Page Tools” to maintain his personal homepage. The scripts performed tasks
such as displaying his résumé and recording his web-page traffic. Lerdorf initially
announced the release of PHP on the comp.infosystems.www.authoring.cgi Use net
discussion group on June 8, 1995.
He rewrote these scripts as Common Gateway Interface (CGI) binaries in C,
extending them to add the ability to work with Web forms and to communicate with
databases and called this implementation “Personal Home Page/Forms Interpreter”
or PHP/FI. PHP/FI could be used to build simple, dynamic Web applications. Lerdorf
released PHP/FI as “Personal Home Page Tools (PHP Tools) version 1.0” publicly
on June 8, 1995, to accelerate bug location and improve the code. This release already
had the basic functionality that PHP has today. This included Perl-like variables, form
handling, and the ability to embed HTML. The syntax was similar to Perl but was more
limited and simpler, although less consistent. A development team began to form and,
after months of work and beta testing, officially released PHP/FI 2 in November 1997.
Zeev Suraski and Andi Gutmans, two Israeli developers at the Technion IIT,
rewrote the parser in 1997 and formed the base of PHP 3, changing the language's
name to the recursive initialism PHP: Hypertext Preprocessor. Afterward, public testing
of PHP 3 began, and the official launch came in June 1998. Suraski and Gutmans then
started a new rewrite of PHP's core, producing the Zend Engine in 1999. They also
founded Zend Technologies in Ramat Gan, Israel.
On May 22, 2000, PHP 4, powered by the Zend Engine 1.0, was released. As of
August 2008, this branch is up to version 4.4.9. PHP 4 is no longer under development
nor will any security updates be released.
On July 13, 2004, PHP 5 was released, powered by the new Zend Engine II.
PHP 5 included new features such as improved support for object-oriented
programming, the PHP Data Objects (PDO) extension (which defines a lightweight and
consistent interface for accessing databases), and numerous performance
enhancements. In 2008 PHP 5 became the only stable version under development.
Late static binding had been missing from PHP and was added in version 5.3.
A new major version has been under development alongside PHP 5 for several
years. This version was originally planned to be released as PHP 6 as a result of its
significant changes, which included plans for full Unicode support. However, Unicode
support took developers much longer to implement than originally thought, and the
decision was made in March 2010 to move the project to a branch, with features still
under development moved to trunk.
Changes in the new code include the removal of register_globals, magic
quotes, and safe mode. The reason for the removals was that register_globals
had opened security holes by intentionally allowing runtime data injection, and the use
of magic quotes had an unpredictable nature. Instead, to escape characters, magic
quotes may be replaced with the addslashes() function, or more appropriately an
escape mechanism specific to the database vendor itself like
mysql_real_escape_string() for MySQL. Functions that will be removed in future
versions and have been deprecated in PHP 5.3 will produce a warning if used.
Many high-profile open-source projects ceased to support PHP 4 in new code as
of February 5, 2008, because of the GoPHP5 initiative, provided by a consortium of
PHP developers promoting the transition from PHP 4 to PHP 5.
Since version 5.4, PHP has native support for Unicode or multibyte strings,
allowing strings as well as class-, method-, and function-names to contain non-ASCII
characters.
PHP interpreters are available on both 32-bit and 64-bit operating systems, but
on Microsoft Windows the only official distribution is a 32-bit implementation, requiring
Windows 32-bit compatibility mode while using Internet Information Services (IIS) on a
64-bit Windows platform. Experimental 64-bit versions of PHP 5.3.0 were briefly
available for MS Windows,

3. Comments, Constants and Variables in PHP


Comments:
Comments in PHP are similar to comments that are used in HTML. The PHP
comment syntax always begins with a special character sequence and all text that
appears between the start of the comment and the end will be ignored.
In HTML a comment's main purpose is to serve as a note to you, the web
developer or to others who may view your website's source code. However, PHP's
comments are different in that they will not be displayed to your visitors. The only way to
view PHP comments is to open the PHP file for editing. This makes PHP comments only
useful to PHP programmers.
PHP Comment Syntax: Single Line Comment
PHP has two types. The first type we will discuss is the single line comment. The
single line comment tells the interpreter to ignore everything that occurs on that line to
the right of the comment. To do a single line comment type "//" or "#" and all text to the
right will be ignored by PHP interpreter.
PHP Code:

Display:

PHP Comment Syntax: Multiple Line Comment


Similiar to the HTML comment, the multi-line PHP comment can be used to
comment out large blocks of code or writing multiple line comments. The multiple line
PHP comment begins with " /* " and ends with " */ ".

PHP Code:
Display:

Constants:
 Constants are the variables whose values are not changed throughout the script.
 A valid constant variable do not have a $ sign before its name.
 It starts with a letter or an underscore (_).
 Constants have global scope in the whole script.
 Constants are useful in situations where same value is used in many places. For
example: if we want to calculate an area and perimeter of a circle, we require the
value of PI in both the cases. So we can have the value of PI defined as a
constant and can use it effectively.
 If we want to create an array of names having length 10, we can define the
length 10 as a constant which will be used anywhere required. But if for some
reason we decided to increase the length to 20, we can just change the value 10
to 20 in the constant definition which will be replicated everywhere.
 Constants are declared using inbuilt define() function.
 It takes 3 parameters,
 Name of the constant
 Value of the constant
 Whether the constant should be case-insensitive. Default value is false.
 The third parameter of define() function is optional.
 The false value of third parameter of define() function denotes that the constant
name is case-sensitive and true value indicates that the constant
name is case-insensitive.

Variables:
 Variable in any programming language is a name given to a memory location that
holds a value.
 You can say that variables are containers for any type of values.
 There are some rules to write variable names in PHP.
 Rules for variable names:
o Variable names in PHP start with a dollar ($) sign followed by the variable
name.
o Variable name can contain alphanumeric characters and underscore (_).
o Variable names must start with a letter or an underscore (_). (For eg:
$abc, $x1, $_g, $abc_1 etc.)
o Variable names cannot start with a number.
o Variable names are case-sensitive. (for eg: $x and $X are treated as two
different variables.)
 In PHP we don’t use any command to declare variables.
 A variable is created as soon as you assign a value to it.
 A variable takes a datatype according to the value assigned to it.
 Since we don’t have to specify datatypes for PHP variables, PHP is called as
loosely typed language.

 Scope of variables:
o Variables can be declared anywhere in the program.
o Scope of a variable is a part of the program where the variable is
accessible.
o PHP has three different variable scopes:
 Local
 Global
 static
o Local scope:
 A variable declared within a function has a local scope and
can be accessed within a function only.
 A function is a small program performing a particular task
which is called when required.
o Global scope:
 A variable declared outside a function has a global scope
and can be accessed outside the function only.
 Actually, global variables can be accessed anywhere using
the global keyword.
o Static scope:
 A variable declared with static keyword is said to have static
scope within the function.
 Normally when variables are executed, they lose their values
or memory.
 But when a variable is declared as static, it doesn’t lose its
value. It remains static within multiple function calls.

4. What is XAMPP?
XAMPP is a local web server. XAMPP stands for Cross-platform, Apache
server, MariaDB, PHP, and Perl. In XAMPP you not need to install each of the individual
components of a web server. The installation is easier and quicker. It is portable and if
you don’t want to run XAMPP automatically every time your computer starts. you need
not install the services.
XAMMP is a simple, lightweight Apache distribution that makes it extremely easy
for developers to create a local web server for testing purposes. Everything you need to
set up a web server – server application (Apache), database (MySQL), and scripting
language (PHP) – is included in a simple extractable file. XAMPP is also cross-platform,
which means it works equally well on Linux, Mac and Windows. Since most actual web
server deployments use the same components as XAMPP, it makes transitioning from a
local test server to a live server is extremely easy as well.

5. What is Apache?
Apache Web Server is an open-source web server creation, deployment and
management software. Initially developed by a group of software programmers, it is now
maintained by the Apache Software Foundation.
Apache Web Server is designed to create web servers that have the ability to
host one or more HTTP-based websites. Notable features include the ability to support
multiple programming languages, server-side scripting, an authentication mechanism
and database support. Apache Web Server can be enhanced by manipulating the code
base or adding multiple extensions/add-ons.
It is also widely used by web hosting companies for the purpose of providing
shared/virtual hosting, as by default, Apache Web Server supports and distinguishes
between different hosts that reside on the same machine.

6. What is MySQL?
MySQL is an open source relational database management system (RDBMS)
based on Structured Query Language (SQL).
MySQL runs on virtually all platforms, including Linux, UNIX, and Windows.
Although it can be used in a wide range of applications, MySQL is most often
associated with web-based applications and online publishing and is an important
component of an open source enterprise stack called LAMP. LAMP is a Web
development platform that uses Linux as the operating system, Apache as the Web
server, MySQL as the relational database management system and PHP as the object-
oriented scripting language. (Sometimes Perl or Python is used instead of PHP.)
MySQL, which was originally conceived by the Swedish company MySQL AB,
was acquired by Sun Microsystems in 2008 and then by Oracle when it bought Sun in
2010. Developers can still use MySQL under the GNU General Public License (GPL),
but enterprises must obtain a commercial license from Oracle.
Offshoots of MySQL are called forks. They include:
 Drizzle – a lightweight open source database management system in
development based on MySQL 6.0.
 MariaDB – a popular community-developed "drop-in" replacement for
MySQL that uses MySQL APIs and commands.
 Percona Server with XtraDB – an enhanced version of MySQL known for
horizontal scalability.

Vous aimerez peut-être aussi