Installing php+apache+mysql is easy on linux. If you are Ubuntu user just go to Synaptyc Package Manager and install php mysql and apache with modules. Your www folder will appear in /var folder.
Installing php on other Linux distributions is easy to, just read the documentation. In some distributions you do not need any installation, like backtrack4 or other....
2. Configure php
Go to your localhost home directory (/var/www on Ubuntu) create phppp (this will be my teaching directory) folder. Go to this directory and create index.php file. Open this file with text editor and type:
<?php
echo "hello world... I am a php script"; // i am single line comment.. i will not be displayed on browser...
?> <br />
<script language="php"> // i don't advise this method.....
echo "i think i am php script, too.."; # i am a single line comment, too..
</script> <br />
<? // you must enable short tag in configuration file
echo "hello, i am short tag";
/*
I
am
multi-line
comment, I will not seen on browser, too...
*/
?> <br />
<% echo "I am ASP tag"; // you must enable asp tag %> <br/>
<?
print ("i am in <b>print()</b> tag.... "); // You can use print without brackets, too.....
printf ("i am in <b>printf()</b> tag.... ");
echo "i am in <b>echo</b> tag... ";
?>
Save it and browse it (localhost/phpp) and you will see: echo "hello world... I am a php script"; // i am single line comment.. i will not be displayed on browser...
?> <br />
<script language="php"> // i don't advise this method.....
echo "i think i am php script, too.."; # i am a single line comment, too..
</script> <br />
<? // you must enable short tag in configuration file
echo "hello, i am short tag";
/*
I
am
multi-line
comment, I will not seen on browser, too...
*/
?> <br />
<% echo "I am ASP tag"; // you must enable asp tag %> <br/>
<?
print ("i am in <b>print()</b> tag.... "); // You can use print without brackets, too.....
printf ("i am in <b>printf()</b> tag.... ");
echo "i am in <b>echo</b> tag... ";
?>
hello world... I am a php script
i think i am php script, too..
hello, i am short tag
I am ASP tag
i am in print() tag.... i am in printf() tag.... i am in echo tag...
And browse page source, you will get this code :i think i am php script, too..
hello, i am short tag
I am ASP tag
i am in print() tag.... i am in printf() tag.... i am in echo tag...
hello world... I am a php script<br />
i think i am php script, too..<br />
hello, i am short tag<br />
I am ASP tag<br/>
i am in <b>print()</b> tag.... i am in <b>printf()</b> tag.... i am in <b>echo</b> tag...
You can configure your php from php directory by editing php.ini find short_tag and asp_tag lines and edit them if you want to enable them...
No comments:
Post a Comment