PHP Basics

PHP Basics

PHP stands for PHP: Hypertext Preprocessor, the old name of PHP was Personal Home Page. Which was later renamed to PHP: Hypertext Preprocessor.
PHP is a server side language used for creating dynamic websites using database. PHP is a powerful language that comes up with many attributes and built-in functions which makes it the best language in web development languages and many popular sites use PHP like Facebook Google etc. As Php is a server side language so it is very secure, only relevant data is visible on the client side.
PHP files are saved with extension .php .

Download PHP:
You can download PHP from the official PHP website.

php tag:
PHP has its own starting and ending tags in which only PHP code can run. You can insert PHP snippets anywhere inside HTML.

PHP Syntax:

Variable in PHP:

Same like JavaScript, PHP is also type independent language. There is no data types of variables in PHP and all the PHP variables are declared using $ sign.

Variable Scope in PHP:

Variables are allowed to declare anywhere in the code there are three scopes of variables in PHP:

  • Static
  • Local
  • Global

Print output in PHP:

To print output in PHP, echo and print keywords are used. They both are same the only difference is that echo does not return any value and take multiple argument, but print return 1 and take only one argument.

Printing variables in output:

Printing variables along string:

Using Print Keyword show output:

HTML tags in PHP: