-
Notifications
You must be signed in to change notification settings - Fork 0
/
basicusage.php
61 lines (54 loc) · 1.72 KB
/
basicusage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* PHP Basic Usage Example Code.
*
* This file shows a very basic example of how PHP
* can be used to generate dynamic content for
* display in a web browser.
*
* @author Xander Shepherd <n00b@n00bsys0p.co.uk>
* @version 0.1
* @package basic-php-usage-example
*/
/**
* Generate the <head> section of the page.
*
* A function to wrap the title in relevant HTML
* tags.
*
* This documentation is in PHPDoc format,
* to allow for ease of documentation production.
*
* @param string $title The page's title
* @return string Formatted HTML <head> section
*/
function generateHeader($title) {
return '<head><title>' . $title . '</title></head>';
}
/**
* Generate the <body> section of the HTML file.
*
* @param string $title The page's title
* @param string $text The paragraph's text.
* @return string Formatted HTML <body> section
*/
function generateBody($title, $text) {
return '<h1>' . $title . '</h1>' . "\n" . '<p>' . $text . '</p>';
}
/**
* Put all the other functions together to produce a full
* HTML page.
*
* @param string $title The document's title
* @param string $content The main content for the page
* @return string Full formatted HTML page
*/
function generateHTML($title = 'Default Title', $content = 'Default Content') {
$head = generateHeader($title);
$body = generateBody($title, $content);
return '<html>' . $head . $body . '</html>';
}
// Main
$content = generateHTML('Page Title!');
print $content;
?>