PHP is a server side scripting language.
Historically web servers were meant to just
deliver prebuilt
HTML files to clients; with
PHP pages you can make the server do some job
like perform calculations, creating files, query
a database and any task you could expect from a
scripting language, with particular attention to
the
HTML code generation.
PHP consists as processing instructions blocks
embedded in
HTML code. From version 5
PHP
is a fully object oriented language.
The
PHP interpeter is usually executed by a web
server (like
Apache), but nothing stops you to
install the interpreter in your system and use it
as a cross-platform scripting language.
The standard mechanism is:
- A client requests a page to a server
- The server parses the PHP scripts embedded in requested page
- The dynamically generated HTML is returned to client
To experiment with
PHP and try my examples, follow these
steps:
- Install a web server with PHP module, and a database server;
the fast way is the following:
- Download XAMPP installer for your platform
- Install it somewhere. I have chosen to use
a virtual pc (Virtualbox), connected to my
real PC with a "bridged adapter" interface
- Put your PHP files in the server C:\xampp\htdocs directory
- Now you can access those files using a browser, using the proper URL,
for example:
- My web server is a pc named vbox_xpsp3,
whose IP address is 193.167.2.331, but
yours probably is localhost (127.0.0.1)
if the web server is running on your local PC
- Put the file basic.php
(that one in PHP files)
in C:\xampp\htdocs,
then open the browser and access it using either
http://vbox_xpsp3/basic.php or
http://193.167.2.331/basic.php
- Now you're ready to experiment and read a good PHP book...