-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2-1_phpBasics.php
More file actions
92 lines (68 loc) · 2.11 KB
/
2-1_phpBasics.php
File metadata and controls
92 lines (68 loc) · 2.11 KB
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
//MODEL - data
//assigning variables and values
$yourName = "Misti Christianson";
$assignment = "2-1: PHP Basics";
$number1 = 100;
$number2 = 73;
$total = $number1 + $number2;
//establishing php array
$wdvLanguages = array('PHP', 'HTML', 'Javascript');
//CONTROLLER - business logic/general code
//function to display php array in order to insert in to javascript array
function displayArray()
{
global $wdvLanguages;
for ($i = 0; $i < 3; $i++) {
echo '"' . $wdvLanguages[$i] . '",';
}
}
// echo displayArray();
//VIEW -user interface
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="styles/stylesheet_flex_responsive.css">
<!-- /**Javascript functions to convert php array to js array and display on html page */ -->
<script>
const wdvLanguages = [<?php displayArray() ?>];
//js function to loop through array and display on page
function displayJSArray() {
text = "";
for (let i of wdvLanguages) {
text += i + " ";
}
document.write("Javascript Array: " + text);
// console.log(text);
}
// console.log("test");
// wdvLanguages.forEach(javascriptArray);
// document.getElementByID("jsArray").innerHTML = "test";
</script>
</head>
<h1>WDV341 Intro PHP: <?php echo $assignment ?> Assignment</h1>
<h2><?php echo $yourName ?></h2>
<h3></h3>
<!-- Display PHP variables on html page -->
<p>Value Number1: <?php echo $number1 ?></p>
<p>Value Number2: <?php echo $number2 ?></p>
<p>Total Value: <?php echo $total ?></p>
<!-- Display javascript array on html page -->
<p>
<script>
displayJSArray();
</script>
</p>
<?php
?>
<p><a href="https://github.com/mistichris/wdv341.git">Git Hub Link</a></p>
<div class="footer">
<a class="" href="../wdv341Homework.php">Christianson WDV321 Homework</a>
<a class="" href="../../index.html">Christianson Home Page</a>
</div>
</body>
</html>