[main] [misc] [graphics] [page design] [site design] [xhtml] [css] [xml] [xsl] [schema] [javascript] [php] [mysql]

HVCC Home
Blackboard HVCC
Blackboard Manual
Faculty Association

php main
1. what is php
2. http basics
3. php basics
4. php expressions
5. php client side
a. writing php content
b. php global arrays
c. php form data
* d. writing the url
6. php flow control
7. php manual


print version

Note that all external links will open up in a separate window.

This is a stripped down version of these pages for older browsers. These pages are really meant to be viewed in a standards compliant browser.

Directions for surfing with audio.

Writing the URL

These tutorials are about XHTML, the Extensible Hypertext Markup Language.

The URL

The URL is called the uniform resource locator for a reason. It is a standard by which anything that can be addressed through the World Wide Web is assigned an address. All URLs take the form of:

scheme:scheme_specific_information

The scheme designates what kind of object is being referenced. The scheme_specific_information designates what object is being referenced.

URLs occur in any mark-up tag that references another document or object. Image tags make use of URLs, as do hyperlinks and style sheet calls. For the most part, everything in a Web page that can reference another document, object, or anchor tag does so in the same way. Once you've got the hang of it, all you have to learn is the occasional exception and everything else is easy.

You will also find URLs called URIs. URI stands for Uniform Resource Indicator and is the official term for URL as it is written in the standards. Unless you are writing a standards manual, the two terms are interchangeable.

Writing the URL

URLs are written in the displayable characters of the ASCII character set. If a character is not displayable, then you shouldn't use it. This particularly includes spaces, which should never be used in the names of Web files and directories. However, if, for some reason, you have to use non-displaying or special characters, they can be represented by a percent sign followed by two hexadecimal digits. This is different from the way special characters are represented in the rest of the XHTML code.

For instance, a space is written as %20. Although, special characters and non-displaying characters in file names are not a good practice, a place this does come in handy is if you need to pass information to a program over the Web. In this case, using character codes is very useful. For instance, if you needed to pass the date to a program in the form of "12/01/99", you could use the following string:

http://www.datefix.com/process?12%2f01%2f99

where %2f refers to the slash ( / ) character. The part of the URL after the question mark is a search string. It is data being passed back to the server for processing.

Any character can be encoded in a URL except those that serve as command delimiters. Thus, the scheme name and the slashes and colon that delimit the sections of the address must be written as themselves to work, however, the rest of the address could be written entirely in special character codes and the address would still work.

If you are hard coding a search string into a URL within the content of your Web pages, it is important that you escape your characters. For instance, if we wanted to code a statement that passed information back to the server that would mimick a form data submission, we might want to write a URL like the following:

[*snip*]/index.php?page=this+one?&from=rulost?

The problem with it is that it contains question marks, which cannot occur in a URL except to separate the resource path from the search string. To encode it as a string literal in our document, we would want to write:

[*snip*]/index.php?page=thisone%3f&from=rulost%3f

Note that we are actually using two separate encoding schemes here, the & to represent the ampersand and the %3f to represent the question marks. The first is an example of HTML or SGML encoding, and is required for proper parsing of an XML document. The second is an example of HTTP encoding and is used to keep an HTTP server from trying to process the special characters.

URL characters that should always be encoded when used as string literals

Character Description Encoding
  Tab %09
  Space %20
; Semicolon %3b
/ Slash %2f
? Question Mark %3f
: Colon %3a
@ At Sign %40
= Equal Sign %3d
& Ampersand %26
< Less Than Sign %3c
> Greater Than Sign %3e
" Double Quotation Mark %22
# Hash Mark %23
% Percent Sign %25
{ Left Curly Brace %7b
} Right Curly Brace %7d
| Vertical Bar %7c
\ Backslash %5c
^ Caret %5e
~ Tilde* %7e
[ Left Square Bracket %5b
] Right Square Bracket %5d
` Grave Accent %60

*The Tilde is an example of characters having different meanings in different contexts. On a UNIX server it is often followed by a user ID as a shorthand for their home directory. If used in a file name, it could cause confusion if not encoded, since it has a special meaning to the server.

[top]