0 ratings0% found this document useful (0 votes) 210 views5 pagesPHP Book
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
71.46
2.24
352
4
© Tolearn how to set up environment of PHP.
© To learn how to declare and assign values to variable of PHP.
@ To study PHP arithmetic using different types of operators.
© To study Arrays and different types of Arrays like indexed array, associative array ang
multidimensional array of PHP.
PHP is recursive acronym “Hypertext Pre-processor" it is a widely used open source
general purpose scripting language that is for developing web applications and its
code can be easily embedded into HTML.
PHP is so popular because it's very simple to learn, code and deploy on server, hence it
has been the popular language amongst the developers.
Like any other scripting language it allows developers to build logic into the creation
of web page'content and handle data returned from a web browser,
PHP also contains a number of extensions that make it easy to interact with
databases, extracting data to be displayed on a web page and storing information
entered by a web site visitor back into the database.
PHP consists of a scripting language and an interpreter, Like other scripting
languages, PHP enables web developers to define the behavior and logic they need in'a
web page.
Features of PHP
Somé unique features of PHP are as follows:
Performance: Scripts written in PHP executes faster than other scripting lan Are
like JSP, ASP.NET and Perl. PHP designed to improve performance through optimized
memory, also third party applications are available which improves the response
time.
i aup (9BA (CA): Sem.)
Bases e
+ Portability: PHP is available for Windows, Uni:
, Unix, MAC OS and
are portable between platforms. Portability means ieee
execute on Unix without any changes.
Program written on windows can
+» Ease of hee It is extremely sophisticated programming language, its syntax is very
clear and consistent. Thats why programmers can easily 0 i
read
is favored for web based applications. ‘ berate
+ Open source: PHP is open source project it means this language is developed by
worldwide team of volunteers who makes it source code freely available. So there is
no licensing fees required. This is an important factor for reducing software
development cost. Also it makes robust because any developer can suggest changes in
the source code of language and it can be added as per guidelines.
+ Third party application support: PHP supports for different wide range of databases,
like MySQL, Postgres SQL, oracle, Microsoft Server. It supports more than fifteen
databases. PHP also supports XML to read and write the documents.
« Widely used: PHP is used on more than millions of websites from pérsonal home
pages to giants like facebook, wikipidea, tumbir, yahoo etc. Also, there are so many
peoples who are using PHP for web development.
| Communication Between Apache Server and Web Browser
* Now we will see how communication takes place between web browser and web
server.
+ When you are accessing a page using browser such as safari or firefox, it cause a little
conversation to. happen over the internet between your computer and another
computer.
+” When PHP is involved the server does more work for its half over the conversation.
1
www.example.com/my.php/test.phpPHP Basics
PHP (BBA (CA): Sem-I0)
1
22
3.
4
5.
6.
‘When you request a PHP page on browser.
Browser sends message over the internet to the computer asking for
www.example.com/my.php/test.php.
Apache server running wwwi.example.com gets this message and ask for PHP engine.
The PHP engine reads the test.php file from the disk drive.
‘The PHP engine runs the commands and access the data with database such as mysql.
1m output and sends back to apache HTTP server in turn
PHP engine takes the progra
apache server sends back the output toyour browser.
e XAMPP, LAMPP or we can download
We can install all in one packages for PHP
and install PHP manually also.
Firstly we will see how we install XAMPP, KAMPP s
MariaDB, PHP and Perl).
o Apache: It is open source web server.
worldwide for delivery of web content. Th
a free software by the Apache Software Foundation.
MySQL/MariaDB: In MySQL, XAMPP contains one of th
database management systems in the world. In combination with the web server
‘Apache and the scripting language PHP, MySQL offers data storage for web
services. Current XAMPP versions have replaced MySQL with MariaDB.
PHP; It is server-side programming language. PHP enables users to create
dynamic websites or applications. PHP can be installed on all platforms and
se database systems.
juagé Perl is used in
Like PHP, Perl also enables users to
ands for cross platform (Apache,
‘Apache is the most widely used server
server application is made available as
e most popular relational
supports a number of dive
Perl; The scripting lang
development, and network programming.
program dynamic web applications.
We can install XAMPP from wow.apach'
jon, currently itis 7.4.7.
run .exe file, yo
system administration, web
efriends.org site where you have to download
its recent vers!
‘After downloading the file, ree to
everything.
If error messages are
make sure that everything un
When successfully installed it will
stop the services and you can configure them
13
xa have to just click on next and 2g
\d open the PHP.ini file, and
not displayed, go to cxxampp/PHP an
der error handling and logging.
show a dashboard through which
e changing the ports etc.
you can start,/
PHP (BBA (CA) : Sern-tM)
Sve Apache SRG See] faa | EY
[Ehsve —yset RRUEITAGR|[ stn] [adi | | eee
sve riezita stat] [Ani] | hep] |
Mereury Stat] [Ramin =
i 7 Hay, 2007)
[windows 6.0 Build 001 Plaeform 2 Service Pack t
Fig. 1.2
Open your browser and enter the URL http://localhost, it will open up the XAMPP
welcome page.
To ensure that the Apache and MySQL servers have been installed on system, restart
your operating system, run the browser, and enter the http://localhost URL again.
You should see the below screen on browser.
~ EBXAMPP for Windows
oeManually installing PHP on windows:
Development environment on Linux
a
Most oftenly you will be able to redirect to home page of XAMPP if yoy can't ey
Sey
(CA): Sem-I0)
you have to stop services which are running on port 80 or you can change tat tt the
apache to another port number. peta
Most commonly service is installed on http port 80 or 8080,
You can save your programs in htdocs folder located in c:/xampp from yh,
willbe fetched on localhost. Ee they
PHP 55 and higher version requires at least windows 8, 2010 or higher very,
windows with 32 bit or 64 bit, You have to check necessary hardware configure
also before installing PHP. BUrations
PHP requires Visual C Runtime (CRT) . Mariy applications requires it soit mp,
installed. ay be.
Installing PHP on a Windows 10 machine is not at all difficult. Fits of ay
understand the steps involved. lets
1. First, we will download the latest PHP package from the PHP website,
2. Once we have the zip file we will create a PHP7 folder in the C drive and: extract th
contents of the zip file in this folder. ie
. Configure php.ini file : you need to make some changes in this file,
Define extension directory: extension_dir="c:\php/ext"
. Change the path environment variable,
. Now open Environment Variables (MyComputer -> System Properties
Environment Variables), under system variables, select Path and click Edit, in the
Variable value, go to the end of the list and put a semicolon, then aéd
C:\php;C:\php\ext assuming C:\php is the location of your PHP installation,
aya
One of the most common server configuration is LAMP stack (Linux, Apache, MysQh,
PHP). We will be using this set up and execute our programs on it. As this is the most
commonly used and easy to install set up of PHP, Also these are all in one packages
For Linux we will try to install, apache, MySQL separately and try not to install thin
party applications.
‘You can still install AAMPP if you would prefer to use that instead, But remembe 8
is a development environment and you should not try use/configure these Y
party applications to run asa live server,
Fi i
irstly we will check system updates for Linux,
sudo apt-get update
Sudo apt-get upgrade
Sudo apt-get dist- upgrade
Ity