Sunday 9 February 2014

Writing Your First php file

Writing Your First Php File
Writing Your First Php File

This is a tutorial for how to write your First php file. In this tutorial we will learn about basic of creating php file what extension we going to give it. How we gonna show inside of the file to ensure that our web-server deals with it correctly because php is important web-server package you may need to specify in apache to look out at php files. you can do this in your http.com file which we looked up when we setup out apache installation. Php is server-side so what ever you write in between php tags would be not able to shown by people usually When you create html tags





<html>
<head>
</head>
<body>
</body>
</html>

Its seems this way will in php code :-

<?php ?>

well we can also specify php code in this way

<? ?>  <?php ?>

codes in this way.


<?php
//every things we write will goes here
?>

You can also combine php and html in pages of webserver.

codes :-

<?php
//your stuff
?>
<html>
//html tags
</html>

<?php
?>

OR

<?
//like that
?>

But i will prefer

<?php
?>

I have made root directory in my localhost to save file localhost/series/firstfile when we will use this link to open our firstfile screenshot1.
Screenshot1

In apache if save file name index.php or index.html it takes as default file whenever we call root directory at localhost it will open index.php bydefault.
Now we create file file.php in series/firstfile it will show you in localhost see screenshot1. Now let see combine php tags and html tags in file and see output
file.php code :-

<?php
?>
<html>
</html>

In this file when we see output screenshot2 let's see output view page source by right click..

Screenshot2

Screenshot3 you can see people can see out html tags well php is server side language so can not be seen by people.php codes are interrupted by web-server. php is server-side scripting language. If we save file name index.php we can not see the page which is in Screenshot2 Index of/series/firstfile and the list of files in it.because by default index.php will open automatically.

Screenshot3
Let create index.php in that i am writing simple commands of php like echo , echo is to use for print anything in output of php file.

Index.php codes:-

<?php

echo 'Hello World.';

?>

Path : localhost/series/firstfile/

first php file
FirstFile
Now you see screenshot6 its similar to screenshot5 just path of screenshot5 is localhost/series/firstfile/ just root directory and in screenshot6 you can see file name index.php same. no need towrite file name because its by default take file in root directory.only index name is configured in apache any other name you should declare with root directory in browser.





No comments:

Post a Comment

Thanks For Comment Will get you Soon..

About Me

Welcome to Extra Tutorials! My name is Mohammed and I am the 22 year writer, website developer, and photographer behind the blog. Thanks for visiting! Tutorials Jackpot… In addition to Developer, I love to develop websites and I love to write. Starting a php Blog was inevitable for me. What began as a simple way to share all of my Tutorials with friends and family has developed into my Part time job.

Mohammed Padela

WHAT IS PHP PROGRAMMING

WHAT IS PHP PROGRAMMING
WHAT IS PHP PROGRAMMING

Follow Us

Popular Posts

Designed ByBlogger Templates