Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a new PHP document (Unit Objective 1) Write a comment similar to the foll

ID: 3883002 • Letter: C

Question

Create a new PHP document (Unit Objective 1)

Write a comment similar to the following: "This is my first PHP document, which displays some data in the web browser"(Unit Objective 1)

Assign your name as a string value into the variable labeled myName (Unit Objective 2)

Assign 53870 numeric value into the variable named randomNumber (Unit Objective 2)

Assign the name of the web browser and operating system of the user accessing the file into the variable named userAgent (Unit Objective 2)

Assign the file name of the currently running script into the variable named fileName (Unit Objective 3)

Assign the IP address from which the user is viewing the current page into the variable named ipAddress (Unit Objective 3)

Use echo command in order to display some informative descriptions followed by the values of myNem, randomNumber, userAgent, fileName, and ipAddress variables in the web browser. Each informative description and the value pair whould be displayed on a separate line (Unit Objective 4)

Save the file as myFirstPHP.php

Create a folder within the public_html folder in your account in people.ysu.edu, name this folder as "e_commerce".

Create another folder within the "e_commerce" folder you just created, and name this folder as "Assignment_1", and upload "myFirstPHP.php" file into the "Assignment_1" folder.

Attach "myFirstPHP.php" file to your response to this assignment, and submit it.

Explanation / Answer

please use the below code for the myFirstPHP.php file to display all the information needed above

<?php
   echo '<p>This is my first PHP document</p>';
   $myName = "Sam";
   echo $myName;
   $randomNumber = 53870 ;
   echo $randomNumber;
   if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$useragent = "Windows";
   echo $useragent;
   } else {
$useragent = "other OS";
   }
   $browser = new BrowserDetection();
   echo 'You are using ', $browser->getBrowser(), ' version ', $browser->getVersion();
  
   // to get the client IP address
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = 'UNKNOWN';
echo $ipaddress;

?>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote