HTML documents are plain-text (also known as ASCII) files that can be created using any text editor (e.g., Emacs or vi on UNIX machines; SimpleText on a Macintosh; Notepad on a Windows machine). You can also use word-processing software if you remember to save your document as "text only with line breaks".
An element is a fundamental component of the structure of a text document. Some examples of elements are heads, tables, paragraphs, and lists. Think of it this way: you use HTML tags to mark the elements of a file for your browser. Elements can contain plain text, other elements, or both.
To denote the various elements in an HTML document, you use tags. HTML tags consist of a left angle bracket (<), a tag name, and a right angle bracket (>). Tags are usually paired (e.g., <H1> and </H1>) to start and end the tag instruction. The end tag looks just like the start tag except a slash (/) precedes the text within the brackets.
Some elements may include an attribute, which is additional information that is included inside the start tag. For example, you can specify the alignment of images (top, middle, or bottom) by including the appropriate attribute with the image source HTML code. Tags that have optional attributes are noted below.
NOTE: HTML is not case sensitive. <title> is equivalent to <TITLE> or <TiTlE>. There are a few exceptions noted in Escape Sequences below.
Not all tags are supported by all World Wide Web browsers. If a browser does not support a tag, it will simply ignore it. Any text placed between a pair of unknown tags will still be displayed, however.
Every HTML document should contain certain standard HTML tags. Each document consists of head and body text. The head contains the title, and the body contains the actual text that is made up of paragraphs, lists, and other elements. Browsers expect specific information because they are programmed according to HTML and SGML specifications.
Required elements are shown in this sample bare-bones document:
<html> <head> <TITLE>A Simple HTML Example</TITLE> </head> <body> <H1>HTML is Easy To Learn</H1> <P>Welcome to the world of HTML. This is the first paragraph. While short it is still a paragraph!</P> <P>And this is the second paragraph.</P> </body> </html>The required elements are the <html>, <head>, <title>, and <body> tags (and their corresponding end tags). Because you should include these tags in each file, you might want to create a template file with them. (Some browsers will format your HTML file correctly even if these tags are not included. But some browsers won't! So make sure to include them.)
; Mode font-lock (couleurs)
(global-font-lock-mode t)
; Mode php
(setq load-path (cons "/home/latour/lisp" load-path))
(require 'php-mode)
Ceci étant fait, pour créer/éditer un fichier, vous n'avez qu'à
lancer la commande:
shell> emacs mon_fichier.php
(Les fichiers PHP ont l'extension ".php")
/home/latour/WWW/bd/exemple/main.php
Lorsqu'on essaie d'obtenir le fichier par l'intermédiaire d'un
browser (mozilla, netscape, explorer,...), en tapant l'URL du
fichier, (dans notre exemple, http://www.student.montefiore.ulg.ac.be/~latour/bd/exemple/main.php
) le serveur http, apache
dans notre cas, va effectuer l'analyse grammaticale du fichier à
l'aide du module php. Le résultat de cette opération est
un nouveau fichier qui est directement envoyé au browser.
Lorque le parser php effectue l'analyse gramaticale d'un fichier, il laisse le
texte inchangé
jusqu'au moment ou il rencontre le tag special <?php
. A ce moment, il commence l'interprétation du code PHP. Le
parser exécute alors tout le code qu'il trouve jusqu'au tag
?>
, qui signale au parser d'envoyer le texte à nouveau
inchangé.
Sans rentrer dans les détails, la syntaxe de PHP est similaire à celle du C et plus précisément à celle de Perl ou des langages de script shell. Une caractéristique fondamentale est qu'on ne déclare pas les types des variables. Le parser PHP attribue un type au variable suivant le contexte. (On peut toutefois explicitement donner un type à une expression en utilisant une opération cast). Pour plus d'info, je vous renvoie au site "officiel" de php: php.net
Note importante pour les étudiants du réseau 8
(1LINF,3ELIN,..)
Pour développer vos scripts php, vous pouvez verifier la syntaxe de
votre code en utilisant PHP en ligne de commande:
shell> php votre_fichier.php > resultat.html
Vous avez alors le resultat du parser php dans le fichier
resultat.html et il indique le premier probleme de syntaxe
rencontré...
louis
comme login et comme
mot de passe.
Fichiers de l'exemple:
exemple.zip