Solved

if inside echo

Posted on 2009-04-03
2
245 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

749 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