PHP stands for "PHP hypertext preprocessor". It's a recursive acronym, just like xinu. Before that it stood for "personal home page" tools, and started because Ramus Lerdorf wanted to keep track of who was looking at his resume.
The goals of PHP are simplicity, a natural way of using databases, and platform independence. Also, it's open source.
Embed code within the html page. Make sure the file is parsed by the httpd serer on the server (generally by ending it with .php). Have the server (not the client) execute the code. Replace the code with the output of the code, and send the result the to the client.
Why execute on the server?
Access to server side resources (large files, databases, etc).
Faster CPU?
More control
But
Increases the server's load
You would not want every file parsed searching for php code. That's why php files get their own extension.
<HTML>
|
All php code goes into a <?php ...> tag. Or it can go
into a <% ... > to lokk like an A.S.P. page. Or it can go
into <SCRIPT language=php> ... </script>.
You can
have any number of php tags in your page. You can find this
page here.
<html> |
Note that there is no "action=" for the form. Instead, the form gets redirected back to this same page after the submit button is hit, only this time with the variable "username" filled in. If you want to go to a different page, then fill in the "action=" part of the form. In fact, notice how the URL of the page changes as you type different things into the form, and then hit the submit button. You are allowed to change the method of the form with the <form method=post>
If you use the default get method
The URL will change to reflect the submitted data.
Anyone can use that URL to see the web page with the data submitted
There is a (rather large) limit on how much data can be sent.
Anyone can see your variable names.
The file will be cached.
If you use the POST method
Sending the URL to someone will not send the data ... they might see a different page.
The file will NOT be cached.
You MUST use the post method to change server state (or the cache will kill you).
Within php code you can use //, #, or /* ... */.
Within HTML
code you can use <!-- ... -->
In real life you can use
<BOGUS ... >, but that's bogus. Any unknown tage will
work, but that's bogus.
To escape special chars, use \. Special chars include ' " \ $
To avoid variable expansion, use ' instead of ".