PHP Script installation, PHP and HTML

After the introduction, we will talk few about the php script installation and the php within html.

Were the php script must be ?

The php script can be a whole file, all the file is a php script, or it may be some part of the page, a small part of a html page.
Anywhere you put your php script, the rule you must follow is that the php script should be contained within the following <?php and ?> Just like that:
<?php
PHP Script go here ...
?>
Example:
<?php
echo "Hello World ! ";
?>
Or may be in a html file:

<html>
<head>
<title>My Page Title here</title>
</head>
<body>
<?php
echo "Hello World ! ";
?>
</body>
</html>

The file ?

Any file that contain a php script should be with .php extention always. If you had your home page index.html, you need to rename it to index.php .

What if I have many pages linking to index.html ? Should I change the link in all pages ?
If there is really many pages that link to index.html, so use the html redirection, you will have two files index.php and index.html that redirect to index.php ! There is always a solution !

What if I don't like the .php extention, I feel that .html is much pretty ?
here is no problem, we can use the rewriting in the apache server, we will se that later :)

2 comments:

Super Bowl Commercials 2012 said...

Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.

kokila zenrays said...

Thanks for sharing this information. Good blog post about PHP, HTML. Really useful informative article. Best PHP training in Bangalore