-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
92 lines (80 loc) · 2.16 KB
/
index.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
// Boolean - a true or false variable
$wordcamp_is_awesome = true;
// Integer - number
$number_of_wordcamps = 4;
// String - text
$warm_greetings = 'Thank you for coming to my session!';
// Array - a group of data in key/value pairs
$array_with_keys = array(
'lunch' => 'yummy',
'sessions' => 'awesome',
'after_party' => "Can't wait!"
);
// An array without key's gets assigned numerical keys automatically
$array_without_keys = array(
'yummy', // 0
'awesome', // 1
"Can't wait!" // 2
);
?>
<!DOCTYPE html>
<html>
<head>
<title>Smallest Theme</title>
</head>
<body>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php /*
<h1><?php echo 'Smallest Theme in PHP'; ?></h1>
<h1><?php echo get_the_title( 1 ); ?></h1>
*/ ?>
<main>
<h1><?php the_title( ); ?></h1>
<?php
// Printing variables to the page
?>
<p>Welcome to WordCamp Nashville #<?php echo $number_of_wordcamps; ?></p>
<p>Lunch was <?php echo $array_with_keys[ 'lunch' ]; ?>.</p>
<?php
// Simple if statement
if ( $wordcamp_is_awesome ) {
$awesomeness = $array_with_keys[ 'sessions' ];
} else {
$awesomeness = "Got ya! It's still awesome";
}
?>
<h3>WordCamp is ... <?php echo $awesomeness; ?>!</h3>
<?php
// You can’t “print” an array without a loop, but you can print single data points.
?>
<h4>Printing Arrays</h4>
<p><?php print_r ( $array_without_keys ); ?></p>
<p><?php echo $array_without_keys[ 1 ]; ?></p>
<?php
// Evaluate using a comparison operator
?>
<h4>Evaluating a variable by comparison</h4>
<?php
if ( $number_of_wordcamps == 4 ) {
echo '<p>This fourth WordCamp is the best.</p>';
}
?>
<?php
// Evaluate using a logical operator
?>
<h4>Evaluating a variable by logical operator</h4>
<?php
if ( $number_of_wordcamps == 4 && $wordcamp_is_awesome ) {
echo "<p>Now you're getting the hang of it.</p>";
}
?>
<?php the_content(); ?>
</main>
<footer>
<h4>Thank you!</h4>
<?php echo $warm_greetings; ?>
</footer>
<?php endwhile; endif;?>
</body>
</html>