Solved

if inside echo

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

777 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