PHP

PHP Intro

PHP is a server-side scripting language designed specifically  for the web. Within an HTML page, you can embed PHP code that will be executed each time the page is visited. Your PHP code is interpreted at the web server and generates HTML or other output that the visitor will see.
PHP was introduced in 1994. As of November 2007, it was installed on more than 21 million domains worldwide, and this number is growing rapidly. You can see the current number at http://www.php.net/usage.php
PHP is an Open Source project. PHP originally stood for Personal Home Page and now stands for PHP Hypertext Preprocessor.
A Simple PHP Script

<?php
echo “Hello Web!”;
 ?>

Output : Hello Web!
Beginning and Ending a Block of PHP Statements
When writing PHP, you need to inform the PHP engine that you want it to execute your commands. If you don’t do this, the code you write will be mistaken for HTML and will be output to the browser. You can designate your code as PHPwith special tags that mark the beginning and end of PHP code blocks.
shows four such PHP delimiter tags.

Tag StyleStart TagEnd Tag
Standard tags<?php?>
Short tags<??>
ASP tags<%%>
Script tags<SCRIPT LANGUAGE=”php”></SCRIPT>

Example 1  :

<?
echo”Hello Web!”;
?>

Example 2 :

<?php
echo”Hello Web!”;
?>

Example  3 :

<%
echo “Hello Web!”;
%>

Example 4 :

<SCRIPT LANGUAGE=”php”>
echo “Hello Web!”;
</SCRIPT>

You can also put single lines of code in PHP on the same line as the PHP start and end tags:

<? echo “Hello Web!”; ?>

Combining HTML and PHP
A PHP Script Incorporated into HTML

<html>
<head>
<title>Listing 3.2 A PHP script including HTML</title>
</head>
<body>
<b>
<?php
echo “hello world”;
?>
 </b>
 </body>
 </html>

As you can see, incorporating PHP code into a predominantly HTML document is simply a matter of typing in the code. The PHP engine ignores everything outside the PHP open and close tags.
You can include as many blocks of PHP code as you need in a single document,interspersing them with HTML as required. Although you can have multipleblocks of code in a single document, they combine to form a single script. Any variables defined in the first block will usually be available to subsequent blocks.

Recommended Tutorials for you


Related posts

How to Fetch data from database Using OOPS In PHP

Anuj Kumar

COOKIES IN PHP

Anuj Kumar

Functions In PHP

Anuj Kumar

PHP – PEAR

Anuj Kumar

How to delete multiple records in PHP

Anuj Kumar

Time Ago Script

Anuj Kumar

How to Salt & Hash a Password using Sha256

Anuj Kumar

How to check Email and username availabilty live using jquery/ajax

Anuj Kumar

Significance and Advantages of PHP Web Development

Anuj Kumar

6 comments

Hallie Demay November 10, 2018 at 6:21 am

I was reading some of your posts on this website and I believe this website is real informative ! Keep putting up.

Reply
Babatundde Fadairo November 10, 2018 at 6:21 am

Nice one, to be the best IT personel in the world is by sharing with people your talent and you will never be forgotten, you are such a greate guy pleasee keep it up.

Reply
Anuj Kumar November 10, 2018 at 6:33 am

THANKS

Reply
Babatundde Fadairo May 17, 2017 at 5:02 pm

Nice one, to be the best IT personel in the world is by sharing with people your talent and you will never be forgotten, you are such a greate guy pleasee keep it up.

Reply
Anuj Kumar May 22, 2017 at 6:42 am

THANKS

Reply
Hallie Demay February 21, 2016 at 11:01 am

I was reading some of your posts on this website and I believe this website is real informative ! Keep putting up.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.