Escolar Documentos
Profissional Documentos
Cultura Documentos
Chapter
GETTING STARTED
WITH HTML
1 Getting Started With HTML
"
When the above code is saved as .html file, and opened in your browser
then it will display:
An HTML web page consists of two parts, the HEAD part and the BODY
part. HEAD part comes before BODY part.
In the HEAD part, you define how the content in the body part of the web
page will be displayed. HEAD part contains the title of the web page, and
formatting of the text, which will be displayed on the body part of the web
page.
All HTML pages begin with <HTML> and end with </HTML>
HEAD part begins with <HEAD> and ends with </HEAD>
'
<HTML>
<HEAD>
<TITLE>This is my First Web page</TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>
Above code will display a blank web page with the title
“This is my First Web page”
Now, lets come to the BODY part. The body part as discussed above
contains the content of the web page.
To display some text in a web page, just add the text in between the body
tag.
<HTML>
<HEAD>
<TITLE>This is my First Web page</TITLE>
</HEAD>
<BODY> My first Web page
</BODY>
</HTML>
The above code will not only display the title “This is my First Web page”
but will also display the text “My first Web page” on the webpage.
Similarly, to make the text look italic, use <i></i> instead of <b></b>
You can also display the text both bold and italic by using <b><i></i></b>
similarly to underline the text use tag <u></u>
For Example:
<HTML>
<HEAD>
<TITLE>This is my First Web page</TITLE>
</HEAD>
<BODY> <b><i>My first Web page</i></b>
</BODY>
</HTML>
To make the text size larger or smaller, use the <font> tag.
<font size=”4” color=”#FFCC00”>Some text</font>
+
Chapter
PHP Basics
2 PHP BASICS
In this chapter you will be able to get know how of PHP language, how it
works and how you can make php scripts easily!
In an HTML page, PHP code is enclosed within special PHP tags. When
a visitor opens the page, the server processes the PHP code and then
sends the output (not the PHP code itself) to the visitor's browser. It
means that, unlike JavaScript, you don't have to worry that someone can
steal your PHP script.
Things to remember:
Save the above code in blank file as webpage.php and run this file in your
browser, you will see the following output:
This text is written with PHP
As you might have noticed that the php code starts with <?php and ends
with ?>
To output we use echo just like in C language.
The above function filesize() displays the size of file in bytes, you can
convert it into Kilobytes by dividing the output by 1024.
<?php
$filesize=filesize("index.html");
$filesizeinkb=$filesize/1024;
echo “$filesizeinkb”;
?>
To round off the value to two decimal places just use the round()
function.
<?php
$filesize=filesize("index.html");
$filesizeinkb=$filesize/1024;
$rounded_value=round($filesizeinkb,2);
echo “$rounded_value”;
?>
"
round (Parameter1,Parameter2);
Parameter 1 is the numeric value that we want to round off and
Parameter 2 is the number of decimal places up to which the number will
be rounded off.
<?php
//Give the value of variable
$value=”75”;
if($value>=”60”){
echo “Pass”;
}else{
echo “Fail”;
}
?>
You can use elseif condition if there are more than two possibilities.
For Example in the code below, we will display “Positive” when variable is
greater than 60 and “Neutral” when variable is equal to 60 and “Negative”
when variable is less than 60, so,
<?php
//Give the value of variable
$value=”60”;
if($value>”60”){
echo “Positive”;
}elseif($value==”60”){
'
echo “Neutral”;
}else{
echo “Negative”;
}
?>
2.10 Loop
Loops are very common in any program. Loop is a repetitive task
assigned to script. Two most common types of loop are “for” and “while”.
For Loop
Here is a sample of a “for” loop:
<?php
for($i=1;$i<=5;$i++){
echo “This is $i line<BR>”;
}
?>
This is 1 line
This is 2 line
This is 3 line
This is 4 line
This is 5 line
Same text is print five times only the line number changes each time.
For loop consists of three parameters each separated by “;” semicolon.
Parameter 1 $i=1 is executed only once.
Parameter 2 $i<=5 is the condition which must be meet to go inside the
loop.
In the above code $i=1, $i is a variable to which I have assigned a value
of 1. The script then checks whether $i is less than or equal to 5, if the
condition is true, then script goes inside the loop. The code inside the
loop is:
While Loop
While loop is similar to for loop, but it only has one parameter.
Look at the code below:
<?php
$i=1;
while($i<=5){
echo “This is line $i<BR>”;
$i++;
}
?>
You can see that initial value of $i is defined outside the loop. Then while
loops checks for the value of $i, if it is less than or equal to 5 then it goes
inside the loop. Inside the loop, the value of $i is increased by 1, so the
loop continues until the value of $i becomes greater than 5.
If you do not increase the value of $i inside the loop, then loop will
continue endlessly, and can cause your system to crash.
Chapter
Using Database
3 USING DATABASE
In the line
$counter_file = file(“stats.txt”);
"