Solved

if inside echo

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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 …

757 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