How Would You Find a Client IP Address?
The internet was developed using the fundamentals of Transmission Control Protocol / Internet Protocol – TCP/IP. This is the set of networking protocols that allows computers to communicate and exchange data. Each networked device: computer, server, tablet, smartphone, etc. has an established IP address that identifies it to other devices across the internet.
- Displaying the IP address of a user on web pages
- Logging history of visitors to a site
- Recognizing new users, to request registration and direct to specific pages
- Identifying repeat visitors, and reacting accordingly with ‘welcome back’ greetings
- Blocking access from certain addresses known to be undesirable or security risks
IP Address Client – Obtaining the Information
As the variable name would indicate, this variable reveals the IP address from the device where the current page is being accessed or viewed.
There are many other valuable elements of information that can be obtained from the $_SERVER superglobal variable:
- $_SERVER[‘SERVER_ADDR’] – Retrieve the IP address of the host server
- $_SERVER[‘SERVER_NAME’] – Determine the actual host server name
- $_SERVER[‘REMOTE_HOST’] – Provides the name of the host in use to view the current page
Do you have to do anything special or write extra code to utilize them? Absolutely not.
Inline Scripts – What are They?
Pros and Cons of Inline Scripts
Note that programmers utilizing inline scripts can also write code to defer loading, so that page construction can continue. Attributes such as ‘defer’ or ‘async’ can be included to control the handling of the inline script.
Writing inline scripts – especially large ones – increases the size of the HTML, which can increase page load time.
One of the advantages of scripting is the capability to reuse code, increasing developer productivity. Inserting an external script where needed makes the code itself easier to read and maintain. Code needed multiple times or in various functions is written once, and included whenever needed.
Ensure that your candidate understands the use of inline and external scripts, and has opinions on their use – including valid reasons for those opinions.
It’s More Than a Matter of Opinion
Best practices should be agreed upon and strictly adhered to by any potential developer candidates.