# PHP | Basics | Advantages| MySQL web development

> Source: https://msatechnosoft.in/blog/php-basics-advantages-mysql-web-development/
> Published: 2017-04-19 · Updated: 2020-07-26
> Publisher: MSA Technosoft (https://msatechnosoft.in/)

## PHP \| Basics \| Advantages \| MySQL  \| Web development

**Hypertext Preprocessor** or [**PHP**](https://msatechnosoft.in/services/php-web-development) is an **open source** **server-side scripting language**. It is mainly used for websites and [**web application development**](https://msatechnosoft.in/services/php-web-development). It can also be embedded in [**HTML**](https://msatechnosoft.in/blog/html-hyperlinks-internal-links-external-links-e-mail-links-html) code. It is most popular **[web development](https://msatechnosoft.in/services/php-web-development) language**. It runs on **UNIX** and **Linux server**. It allows creating [**dynamic websites**](https://msatechnosoft.in/services/php-web-development) with the great user interface and rich features at low cost.

It is used to manage dynamic content, databases, session tracking to build entire e-commerce sites.it can easily be integrated with a number of popular databases including **MySQL**, **Oracle**, **Sybase** and **MS SQL Server**. It supports a large number of major protocols such as **IMAP**, **POP3**, and **LDAP**. **PHP4** supports java and distributed object architecture.

---

## Advantages of PHP

**PHP** is a very popular language for building dynamic [web applications](https://msatechnosoft.in/blog/categories-of-web-applications-characteristics-of-web-applications). It is able to interact easily with any kind of database for all type of content. Best combination of the database with **PHP** is **MySQL**.

**PHP** solutions are cost effective. It runs on Linux server that is absolutely free. Database connectivity is also cheap in PHP development. It uses **MySQL** database that is free of cost.

**PHP** codes run in its own memory space hence its run faster. That is the reason why [**PHP applications**](https://msatechnosoft.in/services/php-web-development) are faster.

---

## How PHP Web solution works

The main goal of **PHP** is to allow [web developers](https://msatechnosoft.in/) to write dynamically generated pages quickly.

When a user visits PHP web page, [web server](https://msatechnosoft.in/blog/web-server-features-of-web-server) processes the **PHP** code. It then sees which part it need to show to the visit (content and images) and hide the other kinds of stuff (file operation, math calculation etc.) then translate **PHP** into [HTML](https://msatechnosoft.in/blog/css-html-link-inline-internal-external-css). After translation, the web page is sent to the user on their web browser.

---

## PHP Basics

**PHP** syntax is easy to understand. It uses c-like syntax. All php coding must be enclosed in php tag

> &lt;?php
> 
> .
> 
> .
> 
> ?&gt;

If file contains php code within html, file must be saved with the extension “.php” instead of “.html”.

> &lt;html&gt;&lt;head&gt;&lt;title&gt; PHP Example&lt;/title&gt;&lt;/head&gt;
> 
> &lt;body&gt;&lt;? php
> 
> Echo “PHP code is embedded with HTML”;
> 
> ?&gt;&lt;/body&gt;&lt;/html&gt;

- White spaces are automatically ignored by php interpreter.
- PHP is Case-Sensitive.
- Statements and expressions are terminated by semi-colons.
- **constant() function:** it is used to return the constant values of the variable.

> &lt;?php
> 
> define(“val1”10);
> 
> echo val1;
> 
> echo constant(“val1”);
> 
> ?&gt;

- **Variable Declaration:** variable is declared with $ in php programming.

> $Variable-name = value;
> 
> Example:
> 
> &lt;?php
> 
> $name= “MSA Technosoft”;
> 
> $description= “Information Technology Company”;
> 
> $no-of-employees= 33;
> 
> ?&gt;

- **Output a String:** To display anything on webpage “echo” is used in php. Quotes cannot be used inside the string. If there is any quote inside the string, put a slash before quote. Use single quote for quotes inside string.

> &lt;?php
> 
> echo “&lt;h3 class=\\ “ special H3\\”&gt; PHP Example&lt;/h3&gt;”;
> 
> echo “&lt;h3 class= ‘special H3’&gt; PHP Example&lt;/h3&gt;;
> 
> ?&gt;

- **Concatenation:** Variables and text strings are joined together with a period symbol(.)

> &lt;?php
> 
> $my-var= “Hello!”;
> 
> $newline= “&lt;br/&gt;”;
> 
> $var1= “Reader”;
> 
> echo $my-var.$var1.$newline;
> 
> echo “Welcome to learn PHP basics”;
> 
> ?&gt;

---

## PHP and MySQL web development

- PHP is the server side scripting language and MySQL is open source relational database. When PHP and MySQL combine together, able to deliver a powerful and cost-effective [web development solution](https://msatechnosoft.in/services/website-design-and-development). It is preferred for its ease of use and simplicity.
- PHP also supports several open source CMS like [WordPress](https://msatechnosoft.in/services/wordpress-web-development), [Drupal](https://msatechnosoft.in/services/drupal-web-development), Joomla etc. It has support for several open source [e-commerce development](https://msatechnosoft.in/services/e-commerce-website-and-application) like [Magento](https://msatechnosoft.in/services/magento-e-commerce-website-application), [OSCommerce](https://msatechnosoft.in/services/os-commerce-development) etc. that helps in building a standard [web solution](https://msatechnosoft.in/services/website-design-and-development) with quality features and services.
- PHP and MySQL together can be built cost effective and efficient web development solution.
- PHP has a great advantage of Interoperability with different operating systems and [web servers](https://msatechnosoft.in/blog/web-server-features-of-web-server). It supports portability.

**3 Components must be installed to develop and run PHP web pages on your PC :**

- **PHP Parser:** it is required to process PHP code and generate HTML output to send to web browser,
- **Database:** PHP usually work with different databases like oracle, Sybase etc. but the best combination is MySQL that is also an open source freeware database, and
- **Web Server:** PHP is able to work with different web servers including Microsoft IIS but the best web server to use with [PHP development](https://msatechnosoft.in/services/php-web-development) is Apache server that is available at free of cost.

Was this post helpful? We would love to here from you. Share your views in the comment section below.

Visit **[Tech Blog](https://msatechnosoft.in/blog)** to stay updated with our latest technology blog post.
