eg-259:lecture16
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
eg-259:lecture16 [2012/03/13 19:38] – [Hello World (PHP)] eechris | eg-259:lecture16 [2013/03/08 18:03] (current) – [Introduction to PHP (Part 1)] eechris | ||
---|---|---|---|
Line 2: | Line 2: | ||
====== Introduction to PHP (Part 1) ====== | ====== Introduction to PHP (Part 1) ====== | ||
- | **Contact Hour 19**: To be discussed | + | **Supplementary Material** |
+ | |||
+ | Provided for Reference. This material is no longer taught | ||
**Lecturer**: | **Lecturer**: | ||
Line 288: | Line 290: | ||
<code php> | <code php> | ||
- | <?php echo("<? | + | < |
- | < | + | |
- | " | + | |
<!-- today.php - A simple example to illustrate a PHP document --> | <!-- today.php - A simple example to illustrate a PHP document --> | ||
- | < | + | <html lang=" |
- | < | + | < |
+ | <meta charset=" | ||
+ | | ||
</ | </ | ||
< | < | ||
Line 306: | Line 308: | ||
</p> | </p> | ||
</ | </ | ||
- | </ | + | </ |
</ | </ | ||
Line 313: | Line 315: | ||
{{eg-259: | {{eg-259: | ||
- | <note warning> | ||
- | The first line of the code | ||
- | <code php> | ||
- | <?php echo("<? | ||
- | </ | ||
- | Is necessary to protect the XML declaration (needed for valid HTML) | ||
- | <code html> | ||
- | <?xml version=" | ||
- | </ | ||
- | from the PHP parser. The code simply asks PHP to //echo// the declaration rather than ecoding it directly in the HTML part of the script. If you do not do this you get this mysterious error message! | ||
- | |||
- | **Parse error**: syntax error, unexpected T_STRING in **C: | ||
- | </ | ||
Line 381: | Line 370: | ||
* Code: | * Code: | ||
<code php> | <code php> | ||
- | <?php echo("<? | + | < |
- | < | + | |
- | " | + | |
<!-- powers.php | <!-- powers.php | ||
An example to illustrate loops and arithmetic | An example to illustrate loops and arithmetic | ||
| | ||
- | < | + | <html lang=" |
- | < | + | < |
+ | <meta charset=" | ||
+ | | ||
</ | </ | ||
< | < | ||
Line 414: | Line 403: | ||
</ | </ | ||
</ | </ | ||
- | </ | + | </ |
</ | </ | ||
Line 446: | Line 436: | ||
---- | ---- | ||
- | < | + | < |
this is not necessarily a good idea! Notice how the end brace for the conditional is separated from the loop body by several unrelated HTML tags. This produces fragile code -- if the second set of PHP tags where removed, a syntax error would occur which might be difficult to track down. | this is not necessarily a good idea! Notice how the end brace for the conditional is separated from the loop body by several unrelated HTML tags. This produces fragile code -- if the second set of PHP tags where removed, a syntax error would occur which might be difficult to track down. | ||
- | </code> | + | </note> |
eg-259/lecture16.1331667481.txt.gz · Last modified: 2012/03/13 19:38 by eechris