?
Solved

if inside echo

Posted on 2009-04-03
2
Medium Priority
?
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
cyberstalker earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

801 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