• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

PHP Syntax

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
Computer Guy
Asked:
Computer Guy
  • 2
1 Solution
 
BurundiLappCommented:
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
 
BurundiLappCommented:
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
 
Ray PaseurCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now