Question

In: Computer Science

: PHP Please read carefully - display the USER info for IP address, web browser and...

: PHP Please read carefully - display the USER info for IP address, web browser and operating system - do not hard code these parts

   1. Create a new PHP document (nit Objective 1)

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

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

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

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

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

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

8. 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)

9. Save the file as myFirstPHP.php

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

   11. 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.

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

Solutions

Expert Solution

Below is the solution:

myFirstPHP.php:

<?php

echo "This is my first PHP document, which displays some data in the web browser.</br>";

$myName = get_current_user(); //assign current user name

// echo $myName; //

$randomNumber = 53870; //assign Numeric value

$os = PHP_OS; //assign OS

function get_browser_name($user_agent) //get the browser info

{

    //check for the each browser like Opera,Edge,Chrome,Safari,Firefox,MSIE etc

if (strpos($user_agent, 'Opera') || strpos($user_agent, 'OPR/')) return 'Opera';

elseif (strpos($user_agent, 'Edge')) return 'Edge';

elseif (strpos($user_agent, 'Chrome')) return 'Chrome';

elseif (strpos($user_agent, 'Safari')) return 'Safari';

elseif (strpos($user_agent, 'Firefox')) return 'Firefox';

elseif (strpos($user_agent, 'MSIE') || strpos($user_agent, 'Trident/7')) return 'Internet Explorer';

return 'Other';

}

echo "Numeric number is : ".$randomNumber."</br>";

echo "Os name is : ".$os."</br>";

echo "Browser name is :".get_browser_name($_SERVER['HTTP_USER_AGENT'])."</br>"; //print the browser info

//get the name of the user who is viewing the current page

$username = getenv('USERNAME') ?: getenv('USER');

echo "User info is : ".$username."</br>"; // e.g. John or Doe-rrr

//get the ip address

$user_ip = $_SERVER['REMOTE_ADDR']; //get the ip address

echo "IP address is : ".$user_ip; // Output IP address [Ex: 177.87.193.134]

?>

sample output:

This is my first PHP document, which displays some data in the web browser.
Numeric number is : 53870
Os name is : WINNT
Browser name is :Edge
User info is : BacktoSchool
IP address is : :160.45.30.20

PLEASE UPVOTE IF FIND THE SOUTION HELPFUL


Related Solutions

PHP Please read carefully - display the USER info for IP address, web browser and operating...
PHP Please read carefully - display the USER info for IP address, web browser and operating system - do not hard code these parts    1. Create a new PHP document (nit Objective 1)    2. Write a comment similar to the following: "This is my first PHP document, which displays some data in the web browser"(Unit Objective 1)    3. Assign your name as a string value into the variable labeled myName (Unit Objective 2)    4. Assign 53870...
Please read the question carefully and then provide the answer thanks. Discussion Topic Choose a TCP/IP...
Please read the question carefully and then provide the answer thanks. Discussion Topic Choose a TCP/IP service, such as a web browser, email, file transfer, remote shell, DHCP, DNS, network time protocol, network address translation, etc. Important! Everyone should pick a different service, if possible, to keep the discussion fresh. In your original post, answer the following about the service you have chosen: How would you determine the IP addresses of your devices on your network? Success Hints You can...
In Kali Linux Write a script that ask the user to enter an IP address and...
In Kali Linux Write a script that ask the user to enter an IP address and a port number, then use the provided entries from the user to perform a query on your local network and determine if the given port is open on the provide network. Need to submit solutions for both below. 1.A short report showing the functionality of your code 2. your bash script
Why would a web developer need to know what browser a user is using? How does...
Why would a web developer need to know what browser a user is using? How does PHP play a role in browser indentification?
Java Program Please Read all directions carefully Write a method named smallToLarge that asks the user...
Java Program Please Read all directions carefully Write a method named smallToLarge that asks the user to enter numbers, then prints the smallest and largest of all the numbers typed in by the user and the average (rounded to 2 decimal places). You may assume the user enters a valid integer number for the number of numbers to read. Here is an example dialogue: /* initialize smallest and largest variables with the 1st user input for Number */ How many...
Isolating bits and bytes Task: Create a program that manages an IP address. Allow the user...
Isolating bits and bytes Task: Create a program that manages an IP address. Allow the user to enter the IP address as four 8 bit unsigned integer values (just use 4 sequential CIN statements). The program should output the IP address upon the users request as any of the following. As a single 32 bit unsigned integer value, or as four 8 bit unsigned integer values, or as 32 individual bit values which can be requested as a single bit...
What is the network address if given this IP address and the following subnet mask?  Please note...
What is the network address if given this IP address and the following subnet mask?  Please note that the network may be different if the subnet mask is different. IP address 178.47.188.176 How many network bits if the following subnet masks? 255.254.0.0 255.255.252.0 255.255.255.248    4. 255.128.0.0     
Please read the instructions and  find attached for the first wiki . Instructions for students: Read carefully...
Please read the instructions and  find attached for the first wiki . Instructions for students: Read carefully the attached document and then post your comments bearing in mind the following questions: 1- What are the pros and cons of rent controls? 2- Why economists disagree on the usefulness of rent control? 3- Do you believe rent control can help the poor? Edit Wiki Content rent control Rent regulation can take various forms, including rent control (the placing of a cap on...
***PLEASE READ CAREFULLY. IF NOT ANSWERED IN FLOWGORITHM PLEASE DON'T ANSWER*** Can you please create a...
***PLEASE READ CAREFULLY. IF NOT ANSWERED IN FLOWGORITHM PLEASE DON'T ANSWER*** Can you please create a flowgorithm chart for the problem below. Also, provide pseudocode as well. Please do not answer if you cannot put into a flowgorithm chart. Pseudocode needed as well. Thank you! Design the logic for a program that outputs every number from 1 through 15 along with its value times 10 and times 100. Make the output look like below: Number is 1 Times 10 is...
Please read the question carefully and relate the situation to the type of antagonist with reasoning...
Please read the question carefully and relate the situation to the type of antagonist with reasoning During anaphylaxis, massive quantities of histamine are released, causing vasodilation that leads to bronchoconstriction. The emergency treatment for anaphylaxis is adrenaline, which causes vasoconstriction that leads to bronchodilation. What type of antagonist/antagonism does this represent? (Physiological, pharmacokinetic, chemical, irreversible, competitive). The thing that confuses me is how to come to the conclusion of what the drug is doing? I'm wondering does adrenaline react with...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT