[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

PHP Syntax

Posted on 2013-05-13
3
Medium Priority
?
185 Views
Last Modified: 2013-05-13
Hi

$Webhost = www.tdl.com;

if ($_SERVER['HTTP_HOST'] !== '$WebHost')

$AbsolutePath = $_SERVER['DOCUMENT_ROOT']."info_here";
$SubDomainHomePath = "info_here";

else

$AbsolutePath = $_SERVER['DOCUMENT_ROOT']."info_here";
$SubDomainHomePath = "info_here";
)
0
Comment
Question by:Computer Guy
[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
3 Comments
 
LVL 6

Expert Comment

by:BurundiLapp
ID: 39161018
if ($_SERVER['HTTP_HOST']  !==  $WebHost)

First thought is that you are enclosing the variable in single quotes which means it won't parse the variable, it will treat it as text.  remove the single quotes or replace with double quotes.
0
 
LVL 6

Accepted Solution

by:
BurundiLapp earned 2000 total points
ID: 39161023
Full thing would be:

$Webhost = www.tdl.com;

if  ($_SERVER['HTTP_HOST']  !==  $Webhost)
{
  $AbsolutePath = $_SERVER['DOCUMENT_ROOT']."info_here";
  $SubDomainHomePath = "info_here";
}
else
{
  $AbsolutePath = $_SERVER['DOCUMENT_ROOT']."info_here";
  $SubDomainHomePath = "info_here";
}

Open in new window


Correct capitalisation of variables is important as well, keep it constant or PHP gets confused.

http://uk3.php.net/manual/en/control-structures.if.php
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39161129
The values of HTTP_HOST and DOCUMENT_ROOT are not immutable.  They are determined by the PHP installation and can be changed by scripts running on the server.  HTTP_HOST can also be affected by rewrite rules.  You may find that what works on one server does not work on another server, so be careful when relying on these values.  

The term "subdomain" is a term of art in web applications.  Please see this link.

As a general rule, HTTP_HOST contains the domain name and will look something like www.example.com.  DOCUMENT_ROOT contains the server path to the "home" directory and will look something like /home/example/public_html.  

Case Sensitivity: Variables, object properties and array indexes are case-sensitive.  The names of functions, classes and methods are not case-sensitive.  Coding standards often call for capitalization of class names or camelCase for methods.  In MySQL the data elements are not case-sensitive unless you ask SQL to treat them that way, however the names of tables and columns are case-sensitive.  File systems are not case-sensitive in Windows, but are case-sensitive in Linux.

Special Characters: To help you write PHP code that is compatible across releases and systems, PHP defines two important special constants.  This is because the values are different depending on the current operating system.  DIRECTORY_SEPARATOR is the value of the slash (or backslash) that is used in file paths.  PHP_EOL is the end-of-line character.  It's wise to use these instead of hardcoding a slash or a slash-n.

A good book that will help you get a foundation in the way PHP works is available here.
http://www.amazon.com/PHP-MySQL-Web-Development-Edition/dp/0672329166/
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

656 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