-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-1_phpFunctions.php
More file actions
137 lines (119 loc) · 4.94 KB
/
3-1_phpFunctions.php
File metadata and controls
137 lines (119 loc) · 4.94 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
//MODEL - data
$time = time();
$inputString = " DMACC has something for everyone! ";
$inputNumber = 1234567890;
$inputCurrency = 123456;
//CONTROLLER - business logic/general code
function formatDate($time)
{
global $time;
echo (date("m/d/Y", $time));
}
function formatInternationDate($time)
{
global $time;
echo (date("d/m/Y", $time));
}
function formatString($inputString)
{
global $inputString;
echo ("1. Number of characters in String: ");
echo strlen($inputString);
echo ('<br>');
echo ("2. Trimmed leading and tailing whitespaces: ");
echo trim($inputString);
echo ('<br>');
echo ("3. String as all lower cases: ");
echo strtolower($inputString);
echo ('<br>');
echo ('4. Does the string contain "DMACC": ');
echo strpos(strtoupper($inputString), 'DMACC');
}
function formatPhoneNumber($inputNumber)
{
global $inputNumber;
$numString = (string)$inputNumber;
$value1 = substr($numString, 0, 3);
$value2 = substr($numString, 3, 3);
$value3 = substr($numString, 6, 4);
echo ("(" . $value1 . ") " . $value2 . "-" . $value3);
}
function formatCurrency($inputCurrency)
{
global $inputCurrency;
echo ('$' . number_format($inputCurrency, 2));
}
//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>WDV341 INTRO PHP</title>
<link rel="stylesheet" type="text/css" href="styles/stylesheet_flex_responsive.css">
<script> </script>
</head>
<body>
<h1>WDV341 Intro PHP</h1>
<h2>Unit-3 PHP Functions</h2>
<ol>
<li>Create a function that will accept a Unix Timestamp as a parameter and format it into
mm/dd/yyyy format.</li>
<p> <?php formatDate($time); ?> </p>
<li>Create a function that will accept a Unix Timestamp as a parameter and format it into
dd/mm/yyyy format to use when working with international dates.</li>
<p> <?php formatInternationDate($time); ?> </p>
<li>Create a function that will accept a string parameter. It will do the following things
to the string:
<ul>
<li>Display the number of characters in the string</li>
<li>Trim any leading or trailing whitespace</li>
<li>Display the string as all lowercase characters</li>
<li>Will display whether or not the string contains "DMACC" either upper or lowercase</li>
<li>
<p> <?php formatString($inputString); ?> </p>
</li>
</ul>
</li>
<li>Create a function that will accept a number parameter and display it as a formatted
phone number. Use 1234567890 for your testing.</li>
<p> <?php formatPhoneNumber($inputNumber); ?> </p>
<li>Create a function that will accept a number parameter and display it as US currency
with a dollar sign. Use 123456 for your testing.</li>
<p> <?php formatCurrency($inputCurrency); ?> </p>
</ol>
<p><a href="https://github.com/mistichris/wdv341.git">Git Hub Link</a></p>
<div class="footer">
<a class="" href="../wdv221Homework.html">Christianson Homework Page</a>
<a class="" href="../../index.html">Christianson Home Page</a>
</div>
</body>
</html>
<!-- Create a PHP page that will process and display the following pieces of information.
Use a combination of custom PHP functions and functions from the PHP API as needed.
Your page should do the following:
1.Create a function that will accept a Unix Timestamp as a parameter and format it into
mm/dd/yyyy format.
2.Create a function that will accept a Unix Timestamp as a parameter and format it into
dd/mm/yyyy format to use when working with international dates.
3.Create a function that will accept a string parameter. It will do the following things
to the string:
Display the number of characters in the string
Trim any leading or trailing whitespace
Display the string as all lowercase characters
Will display whether or not the string contains "DMACC" either upper or lowercase
4.Create a function that will accept a number parameter and display it as a formatted
phone number. Use 1234567890 for your testing.
5.Create a function that will accept a number parameter and display it as US currency
with a dollar sign. Use 123456 for your testing.
When complete please do the following:
Post all necessary files to your website.
Update your WDV341 homework page with a link to the assignment. If your assignment
is not on your website it will not be graded.
Include a link to your Git repo on the Blackboard assignment. If your assignment is
not in your Git repo it will not be graded.
Place a link to your homework page on the Blackboard assignment.
Submit your assignment on Blackboard. If you do not submit the assignment on
Blackboard it will not be graded. -->