GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/nginx/html/JimMartinson/CST1146/Labs/Lab03/ |
Upload File : |
<? // JimMartinson/CST1146/Labs/Lab03/Lab03.phpinc #if ( $_SESSION['userId'] == 1 ) $showEvaluationVariables = true; require('Gradebook/EvaluationSubmission_BEGIN.phpinc'); // Replaced. #if ( $_SESSION['userId'] != 1 ) { require('Gradebook/EvaluationSubmission_END.phpinc'); exit; } include('common/Browser/Browser.phpinc'); $disabled = ''; $disabled = ' disabled'; // Comment this line to enable lab. // NOTE: Disable Include conf/extra/httpd-autoindex.conf line in the httpd.conf file before labs. // OR: Fix labs so Lab 4 mod_autoindex works as it should. ?> <fieldset><legend><?=$evaluationType?> <?=$evaluationNumber?> Description</legend> The purpose of this lab is to create your first PHP document and demonstrate the use of some PHP variables. <?=$gradeNote?> <? if ( $disabled ) { ?><span class="error bold">Notice: Do not perform this assignment unless this notice has been removed.</span><? } ?> </fieldset> <fieldset><legend><?=$evaluationType?> <?=$evaluationNumber?> Instruction</legend> <ol class="count"> <!-- 1 --> <li>Create a directory called <b class="copyText"><?=$evaluationName?></b> in your <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?></b> directory. We will use it for all work performed in this lab.</li> <!-- 2 --> <li>Create a PHP file called <b class="copyText"><?=$saveFilename?>.php</b> in the <b><?=$evaluationName?></b> directory and open it in an editor. <br>All code below will be written into this file.</li> <!-- 3 --> <li>Declare some PHP variables: <ol> <li>A variable named <b class="copyText">labNumber</b> with a value of <b class="copyText"><?=$evaluationNumber?></b>.</li> <li>A variable named <b class="copyText">myName</b> with a value of <b class="copyText"><?=$userFullName?></b>.</li> </ol> </li> <!-- 4 --> <li>End php (<span class="copyText php">?></span>) then copy and paste the following boilerplate HTML code into your document: <pre class="copyText html"><!DOCTYPE html> <html lang="en"> <head> <title>Lab <note>replace_by_output_of_the_labNumber_variable</note> - <note>replace_by_output_of_the_myName_variable</note></title> <meta charset="utf-8"> <head> <body> <h1>Lab <note>replace_by_output_of_the_labNumber_variable</note> - <note>replace_by_output_of_the_myName_variable</note></h1> This is my first PHP page. <br>More code and HTML goes below here.<br> replace_this_with_code_and_html_from_the_instructions_below </body> </html> </pre> </li> <!-- 5 --> <li>Replace both instances of <span class="html"><note>replace_by_output_of_the_labNumber_variable</note></span> by printing out the <b>labNumber</b> variable. <br><note>It does not matter if you use the echo, print, or shorthand syntax.</note> </li> <!-- 6 --> <li>Replace both instances of <span class="html"><note>replace_by_output_of_the_myName_variable</note></span> by printing out the <b>myName</b> variable. <br><span class="note normal">Replace <span class="html"><note>replace_this_with_code_and_html_from_the_instructions_below</note></span> with the code you create from the instructions below.</span> </li> <!-- 7 --> <li>Declare some more PHP variables: <note>Remember to do this by replacing <span class="html"><note>replace_this_with_code_and_html_from_the_instructions_below</note></span>.</note> <ol> <li>A variable named <b class="copyText">numberOne</b> with a value of <b class="copyText">5</b>.</li> <li>A variable named <b class="copyText">numberTwo</b> with a value of <b class="copyText">3</b>.</li> <li>A variable named <b class="copyText">textOne</b> with a value of <b class="copyText">123text</b>.</li> <li>A variable named <b class="copyText">textTwo</b> with a value of <b class="copyText">A string of text</b>.</li> </ol> </li> <!-- 8 --> <li>Place the following <span class="html">HTML</span> and <span class="html"><note>your PHP code</note></span> into your document: <pre class="copyText html"> <br>numberOne has a value of <note>(Output the value of numberOne here)</note>. <br>numberTwo has a value of <note>(Output the value of numberTwo here)</note>. <br>textOne has a value of <note>(Output the value of textOne here)</note>. <br>textTwo has a value of <note>(Output the value of textTwo here)</note>. <br>numberOne plus numberTwo has a value of <note>(Output the value of numberOne plus numberTwo here)</note>. <br>numberOne plus textOne has a value of <note>(Output the value of numberOne plus textOne here)</note>. <br>numberOne concanted with numberTwo has a value of <note>(Output the value of numberOne concanted with numberTwo here)</note>. <br>textOne concanted with textTwo has a value of <note>(Output the value of textOne concanted with textTwo here)</note>. </pre> </li> <!-- 9 --> <li>Create a function called localFunc with the following code: <pre class="copyText php">function localFunc() { if (!isset($x)) { $x = 5; } echo '<div style="background-color:#ff8;">'."\nIn localFunc<br>\n"; echo '$x=', $x, "<br>\n"; $y = $x + 5; echo '$y=',$y, "<br>\n"; $x++; echo '$x=',$x, "<br>\n"; echo "</div>\n"; }</pre> </li> <!-- 10 --> <li>A variable named <b class="copyText">x</b> with a value of <b class="copyText">1</b>.</li> <!-- 11 --> <li>Do the following three times: <ol> <li>Call the <b>localFunc</b> function.</li> <li><php class="copyText">echo 'After localFunc $x = ', $x,"<br>\n";</php></li> </ol> </li> <!-- 12 --> <li>Create a function called globalFunc with the following code: <pre class="copyText php">function globalFunc() { echo '<div style="background-color:#8ff;">'."\nIn globalFunc<br>\n"; echo "\$GLOBALS['x']=", $GLOBALS['x'], "<br>\n"; $y = $GLOBALS['x'] + 5; echo '$y=',$y, "<br>\n"; $GLOBALS['x']++; echo "</div>\n"; }</pre> </li> <!-- 13 --> <li>Do the following three times: <ol> <li>Call the <b>globalFunc</b> function.</li> <li><php class="copyText">echo 'After globalFunc $x = ', $x,"<br>\n";</php></li> </ol> </li> <!-- 14 --> <li>Declare some more PHP variables: <ol> <li>A variable named <b class="copyText">myNameString</b> with a value of <b class="copyText">myName</b>.</li> <li>A variable named <b class="copyText">variableVariable</b> with a value of <b class="copyText">$$myNameString</b> <br><note>Note: $$myNameString is not a string, it is a variable variable name. Note the use of two dollar signs ($$).</note></li> </ol> </li> <!-- 15 --> <li>Place the following <span class="html">HTML</span> and <span class="html"><note>your PHP code</note></span> into your document: <pre class="copyText html"> <br>This is an example of a variable variable: <br>myNameString has a value of <note>(Output the value of numberTwo here)</note>. <br>variableVariable has a value of <note>(Output the value of variableVariable here)</note>. </pre> </li> <!-- 16 --> <li>Verify that your page works. <ol type="i"> <li>Start Apache if it is not running.</li> <li>Open up a browser.</li> <li>In the address bar enter <b class="copyText">http://localhost/CST1146/<?=$evaluationName?>/</b> and hit enter.</li> <li>Click on your <b><?=$saveFilename?>.php</b> file. <br>You should see a page like:<br> <? BrowserBegin('Lab '.$evaluationNumber.' - '.$userFullName,'http://localhost/CST1146/'.$saveFilename.'.php',820); ?> <h1 class="left">Lab <?=$evaluationNumber?> - <?=$userFullName?></h1> This is my first PHP page. <br>More code and HTML goes below here.<br> <br>numberOne has a value of 5. <br>numberTwo has a value of 3. <br>textOne has a value of 123text. <br>textTwo has a value of A string of text. <br>numberOne plus numberTwo has a value of 8. <br>numberOne plus textOne has a value of <br /> <b>Warning</b>: A non-numeric value encountered in <b>C:\Data_WWW\CST1146\Lab03\<?=$saveFilename?>.php</b> on line <b>26</b><br /> 128. <br>numberOne concanted with numberTwo has a value of 53. <br>textOne concanted with textTwo has a value of 123textA string of text. <div style="background-color:#ff8;"> In localFunc<br> $x=5<br> $y=10<br> $x=6<br> </div> After localFunc $x = 1<br> <div style="background-color:#ff8;"> In localFunc<br> $x=5<br> $y=10<br> $x=6<br> </div> After localFunc $x = 1<br> <div style="background-color:#ff8;"> In localFunc<br> $x=5<br> $y=10<br> $x=6<br> </div> After localFunc $x = 1<br> <div style="background-color:#8ff;"> In globalFunc<br> $GLOBALS['x']=1<br> $y=6<br> </div> After globalFunc $x = 2<br> <div style="background-color:#8ff;"> In globalFunc<br> $GLOBALS['x']=2<br> $y=7<br> </div> After globalFunc $x = 3<br> <div style="background-color:#8ff;"> In globalFunc<br> $GLOBALS['x']=3<br> $y=8<br> </div> After globalFunc $x = 4<br> <br>This is an example of a variable variable: <br>myNameString has a value of myName. <br>variableVariable has a value of <?=$userFullName?>. <? BrowserEnd(); ?> If this is not what you see then you have errors in your code. </li> <li><b class="info">Take a screenshot of the page</b> and save the image as <b class="copyText"><?=$saveFilename?>.png</b> in your <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?><?=$dirSep?><?=$evaluationName?></b> directory. <br>Make sure that the address bar is visible in your browser before saving the image. </li> </ol> </li> <!-- 17 --> <li>Turn in your assignment: <ol> <li>Ensure the following files are in your <b><?=$evaluationName?></b> folder. <br><?=$saveFilename?>.php <br><?=$saveFilename?>.png </li> <li>Zip up your <b><?=$evaluationName?></b> folder into a file named <b class="copyText"><?=$uploadFilename?></b>.</li> <li>Browse and select your <b><?=$uploadFilename?></b> file: <input type="file" name="fileUpload" id="inpFileUpload"<?=$disabled?>><div id="divFileploadError"></div></li> <li>Then <input type="submit" name="f_subtask" id="inpSubmit" value="Submit"<?=$disabled?>> for grading.</li> </ol> </li> </ol><? if ( $disabled ) { ?><span class="error bold">Notice: Do not perform this assignment unless this notice has been removed.</span><? } ?> </fieldset> <? require('../LabNotes.phpinc'); require('Gradebook/EvaluationSubmission_END.phpinc'); // Replaced. ?>