Solved

if inside echo

Posted on 2009-04-03
2
240 Views
Last Modified: 2012-05-06
How can I consolidate these two lines into one line that begins with echo?
if(isset($_SERVER['HTTPS'])) $https = 's'; else $https = '';

echo 'http' . $https . '://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"],PHP_URL_PATH);

Open in new window

0
Comment
Question by:hankknight
2 Comments
 
LVL 10

Accepted Solution

by:
cyberstalker earned 500 total points
ID: 24062079
echo isset($_SERVER['HTTPS']) ? 'https://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"],PHP_URL_PATH) : 'http://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"],PHP_URL_PATH)
0
 
LVL 16

Author Comment

by:hankknight
ID: 24062190
Thanks!  I modified your code:
header("Location: " . (isset($_SERVER['HTTPS']) ? 'https://' : 'http://') . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"],PHP_URL_PATH),301);

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now