Basic Aspects of PHP | Class Assignment | By Cindy Bryant


1. What is PHP?

  • PHP stands for PHP: Hypertext Preprocessor
  • PHP is a server-side scripting language (Server-side scripting is a web server technology in which a user’s request is verified by running a script directly on the web server to generate dynamic web pages), like ASP
  • PHP scripts are executed on the server
  • PHP supports many databases (MySQL, Oracle, Sybase, Solid, etc.)
  • PHP is an open source software
  • PHP is free to download and use

2. Describe briefly the history of PHP.

As a web language PHP is without a doubt the most popular server language currently in use. PHP was founded in 1995 by Rasmus Lerdorf, because he needed to build a tool that would track the access to his web page. He used C to create his tools and then he released his tools to open source community under the name PHP/FI (PHP Form Interpreter).

In the first release it had many syntax similarities with Perl and in 1997 PHP 2 was released with some new features. In 1998 PHP 3 was released with many more flexible features in it. And even in that stage it’s said to have occupied 10% of web servers.

PHP 4 came in the year 2000 and it brought a new look to PHP language. A new object oriented look, which resulted in initiating many new web trends such as CMS and Frameworks. In 2004, PHP 5 was released with enhanced OOP abilities.

3. Describe general usage of PHP like server-side scripting, command-line scripting, and client-side GUI applications.

PHP is a general-purpose server-side scripting language originally designed for Web development to produce dynamic Web pages. It is among one of the first developed server-side scripting languages to be embedded into an HTML source document, rather than calling an external file to process data. Ultimately, the code is interpreted by a Web server with a PHP processor module which generates the resulting Web page. It also has evolved to include a command-line interface capability and can be used in standalone graphical applications. Any PHP code in a requested file is executed by the PHP runtime, usually to create dynamic Web page content or dynamic images used on Web sites or elsewhere. It can also be used for command-line scripting (Unlike web scripts, Command line scripts doesn’t have any maximum execution time limit and they can run as long as they can, unless until the server shuts down. Using command line scripting, we can accomplish many time consuming tasks like taking backup of entire website and databases, transferring files to another server through ftp, and many more), and client-side GUI applications. PHP can be deployed on most Web servers, many operating systems and platforms, and can be used with many relational database management systems (RDBMS). It is available free of charge, and the PHP Group provides the complete source code for users to build, customize and extend for their own use.

PHP acts primarily as a filter, taking input from a file or stream containing text and/or PHP instructions and outputting another stream of data; most commonly the output will be HTML.

Web content management systems written in PHP include Joomla, WordPress, Drupal. All Web sites created using these tools are written in PHP, including the user-facing portion of Wikipedia, Facebook, and Digg.

4. Explain basic PHP syntax.

A PHP scripting block always starts with <?php and ends with ?>. A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code. Below, we have an example of a simple PHP script which sends the text “Hello World” to the browser:


echo “Hello World”;


Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another.

There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text “Hello World”.

Note: The file must have a .php extension. If the file has a .html extension, the PHP code will not be executed.

In PHP, we use // to make a single-line comment or /* and */ to make a large comment block.

Variables are used for storing values, like text strings, numbers or arrays.All variables in PHP start with a $ sign symbol. The correct way of declaring a variable in PHP:

$var_name = value;


$txt=”Hello World!”;

PHP is a Loosely Typed Language: In PHP, a variable does not need to be declared before adding a value to it. PHP automatically converts the variable to the correct data type, depending on its value.

Naming Rules for Variables:

  • A variable name must start with a letter or an underscore “_”
  • A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _ )
  • A variable name should not contain spaces. If a variable name is more than one word, it should be separated with an underscore ($my_string), or with capitalization ($myString)

5. Explain how PHP can be applied to a website.

To get access to a web server with PHP support, you can:

  • Install Apache (or IIS) on your own server, install PHP, and MySQL
  • Or find a web hosting plan with PHP and MySQL support

If your server supports PHP you don’t need to do anything. Just create some .php files in your web directory, and the server will parse them for you. Because it is free, most web hosts offer PHP support. However, if your server does not support PHP, you must install PHP.

PHP enjoys such widespread popularity because:

  • It is easy to learn: Its C-like syntax makes it an easy language to learn for programmers and nonprogrammers alike.
  • It blends well with HTML: You can mix PHP scripts right inside your HTML or place HTML tags and code inside PHP files.
  • PHP has a vast library of functions and APIs: PHP’s ability to interact with LDAP, databases and the file system makes it a great “one stop shop” for developers.
  • You can rapidly create Web applications and database-backed applications: PHP is so often used with databases, especially open-source databases, that several books are available on the shared topic of PHP and MySQL.
  • It is cross-platform capable: PHP is used on Windows, Linux, commercial flavors of Unix and MacOS X.