Introduction to PHP || Server Side Scripting || BCIS Notes

Introduction to PHP || Server Side Scripting || BCIS Notes

Introduction to PHP

PHP stands for Hypertext Preprocessor. It is a very popular and widely-used open-source server-side scripting language to write dynamically generated web pages. It was originally created by Rasmus Lerdorf in 1994. It was initially known as Personal Home Page.

Its scripts are executed on the server and the result is sent to the web browser as plain HTML. It can be integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Microsoft SQL Server, Sybase, and so on. The current major version of PHP is 7.

What You Can Do with PHP

There are lot more things you can do, they are:

  • You can generate pages and files dynamically.
  • You can create, open, read, write and close files on the server.
  • You can collect data from a web form such as user information, email, phone no, etc.
  • You can send emails to the users of your website.
  • You can send and receive cookies to track the visitor to your website.
  • You can store, delete, and modify information in your database.
  • You can restrict unauthorized access to your website.
  • You can encrypt data for safe transmission over the internet.

Setting Up a Local Web Server

The script executes on a web server. So before you start writing any program you need the following program installed on your computer.

  • The Apache Webserver
  • The PHP engine
  • The MySQL database server

You can either install them individually or choose a pre-configured package for your operating systems like Linux and Windows. Popular pre-configured packages are XAMPP and WampServer.

WampServer is a Windows web development environment. It allows you to create web applications with Apache2, PHP, and a MySQL database. It will also provide the MySQL administrative tool PhpMyAdmin to easily manage your databases using a web browser.

The official website for downloading and installation instructions for the WampServer: http://www.wampserver.com/en/

Creating Your First PHP Script

Click on the WampServer icon somewhere on your Windows taskbar and select the “www directory”. Alternatively, you can access the “www” directory by navigating the C:\wamp\www. Create a subdirectory in the “www” directory let’s say “project”.

Now open up your favorite code editor and create a new PHP file then type the following code:

PHP

Alternatively, you can access the “hello.php” file by selecting the localhost option and then select the project folder from the WampSever menu on the taskbar.

It can be embedded within a normal HTML web page. That means inside your HTML document you can write the PHP statements, as demonstrated in the following example:

Standard PHP Syntax

A  script starts with the <?php and ends with the ?> tag.
The delimiter <?php and ?> in the following example simply tells the engine to treat the enclosed code block as PHP code, rather than simple HTML.Standard PHP Syntax

If you liked our content Introduction to PHP, then you will also like jQuery Methods

Be the first to comment

Leave a Reply

Your email address will not be published.


*