Writing Your First Php File |
<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/
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..