Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Download
Standard view
Full view
of .
Add note
Save to My Library
Sync to mobile
Look up keyword
Like this
8Activity
×
0 of .
Results for:
No results containing your search query
P. 1
Starting of Php with Simplest Codes and examples

Starting of Php with Simplest Codes and examples

Ratings: (0)|Views: 1,901|Likes:
Published by Dinesh Verma

More info:

Published by: Dinesh Verma on Jun 18, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, DOC, TXT or read online from Scribd
See More
See less

08/27/2012

pdf

text

original

 
Hypertext Pre-processor: What is PHP?
What is PHP?
Hypertext Pre-processor (PHPs) is a
 server-side
scripting language, and
 server-side
scripts are specialcommands you must place in Web pages. Those commands are processed before the pages are sent fromyour Server to the Web browser of your visitor. A typical PHP files will content commads to be executedin the server 
 
in addition to the usual mixture of text and HTML (Hypertext Markup Language) tags.When you type a URL in the Address box or click a link on a Web page, you're asking a Web server on acomputer somewhere to send a file to the Web browser (sometimes called a "client") on your computer. If that file is a normal HTML file, it looks exactly the same when your Web browser receives it as it did before the Web server sent it. After receiving the file, your Web browser displays its contents as acombination of text, images, and sounds. In the case of an PHP page, the process is similar, except there'san extra processing step that takes place just before the Web server sends the file. Before the Web server sends the PHP file to the Web browser, it runs all server-side scripts contained in the page. Some of thesescripts display the current date, time, and other information. Others process information the user has justtyped into a form, such as a page in the Web site's guestbook To distinguish them from normal HTML pages, PHP files are usually given the ".php" extension.
What Can You Do with PHP?
There are many things you can do with PHP.
You can display date, time, and other information in different ways.
You can make a survey form and ask people who visit your site to fill it out, send emails, save theinformation to a file, etc
What Do PHP pages Look Like?
The appearance of an PHP page depends on who or what is viewing it. To the Web browser that receivesit, an Active Server Page looks just like a normal HTML page. If a visitor to your Web site views thesource code of an PHP page, that's what they see: a normal HTML page. However, the file located in theserver looks very different. In addition to text and HTML tags, you also see server-side scripts. This iswhat the PHP page looks like to the Web server before it is processed and sent in response to a request.
What Do PHP pages Look Like?
Server-side scripts look a lot like HTML tags. However, instead of starting and ending with lesser-than ( <) and greater-than ( > ) brackets, they typically start with <?php or <? and will typically end with ?>. The<?php or <? are called an
opening tags
, and the ?> is called a
closing tag 
. In between these tags are theserver-side scripts. You can insert server-side scripts anywhere in your Web page--even inside HTML tags.
Do You Have to Be a Programmer to Understand Server-Side Scripting?
There's a lot you can do with server-side scripts without learning how to program. For this reason, muchof the online Help for PHP is written for people who are familiar with HTML but aren't computer  programmers.1
 
Creating my first PHP file
In this page we will add PHP scripting languaje codes to our regular HTML page, we will learn how towrite texts and how to concatenete them and write some special characters, and we will start usingvariables.In our fisrt step to learn PHP scripting languaje we will modify a regular HTML page and we will add to itPHP commads. Bellow we will find a regular HTML page:
mypage.html
<html><head><title>This is my page</title></head><body>This is the content of my page.</body></html>To create a PHP page using the page above as our model, the first important action is to rename our file. Inour case we will name the file "
mypage.php
". When a file with ".php" extension is placed in the server and the corresponding url is visited, the server will process the file before sending it to the client, so thatall PHP commands will be processed. We may just change the name of our file as propoused and save itto our server (without any additional changes), and when visiting the corresponding URL the result will beexactly the same (because there is nothing to be processed in the page) .To this renamed page ("mypage.php") we will add a small PHP command within
<?php
opening tag 
and
?>
 
closing tag 
.
mypage.php
<html><head><title>This is my page</title></head><body>This is the content of my page.
<?phpprint "Do you like it?";?>
</body></html>2
 
When visiting the page, the server will process the page to execute all PHP commands in the page, whichwill be located within
<?php
opening tag 
and
?>
 
closing tags.
In our case "print" command will writeto the resulting page the text contained between brakets ("Do you like it?"). Often, instead of printcommand, echo command is used to output string. At the end of the line we will add
";"
(otherway wewill get an error). We may use "echo" command instead of "print", and the result will be identical.We may also include all the php commands in one line by placing the code bellow in our page.
<?php print "Do you like it?"; ?>
Between
opening 
and
closing tags
we may include several lines with executable commands as shown bellow (we must write
";"
at the end of each line):
mypage.php
<html><head><title>This is my page</title></head><body>This is the content of my page.
<?phpprint "Do you like it?";print "<br>";print "<b>If not, please visit a different page.</b>";print "<br>";print "<h1>Goodbay</h1>";?>
</body></html>Additionaly we may add several
opening 
and
closing tags
within our page with executable commands.3

Activity (8)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Gopal Shinde liked this
Sameera Mohammed liked this
amitgoyal1979 liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->