Jump to content

Need help with Constants


doubledee

Recommended Posts

I would like to define two constants to switch where my "Web Root" is located so I can go between my laptop and web host.

 

I created a "config.inc.php"

 

<?php
// Constants for Web Roots.
define('DEV_ROOT', '/00_MyWebsite/');
define('PROD_ROOT', 'w w w.MyWebsite.com/');
?>

 

and then in my "checkout.php" page I have...

 

<body>
<!-- Access Web Root Constants -->
<?php	require_once "../config.inc.php";
			echo 'DEV _ROOT = ' . DEV_ROOT;
			echo 'PROD _ROOT = ' . PROD_ROOT;
?>

 

But that doesn't seem to work so far.

 

I know what I'm trying to do, but am getting stuck on how to do it?!  :confused:

 

Can someone help straighten me out??

 

Thanks,

 

 

 

Debbie

 

 

Link to comment
Share on other sites

What do you mean by " that doesn't seem to work so far." What is happening or not happening?

 

Ken

 

I switched where my echo was at and it seems like my constants are at least printing now.  (Strange behavior!!  I think since all of my links and includes are toast things are acting strangely?!)

 

I got this...

 

DEV_ROOT = localhost/00_MyWebsite/

PROD_ROOT = www.MyWebsite.com/

 

 

So, anyhow, here is a slightly larger code snippet...

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<!-- Include HTML Metadata -->
<?php	require_once "../components/html_meta.inc.php";	?>

<!-- Page Stylesheets -->
<link type="text/css" rel="stylesheet" href="../css/pagelayout_3col3.css" />
<link type="text/css" rel="stylesheet" href="../css/dropdown04.css" />
<link type="text/css" rel="stylesheet" href="../css/footer-.css" />
</head>

<body>
<!-- Access Web Root Constants -->
<?php	require_once "../config.inc.php";	?>


<div id="wrapper" class="clearfix">
	<div id="inner">
		<!-- Include BODY HEADER -->
			<?php	//require_once "../components/body_header.inc.php";	?>

 

How can I hook up the above file paths to a Constant so that I get the desired effect when I'm on my laptop or web host, respectively?

 

 

 

Debbie

 

 

Link to comment
Share on other sites

I'm really struggling with file paths today...  :'(

 

Here is my local directory structure...

 

00_MyWebsite
Source Files
	components
		body_header.inc.php
		body_footer.inc.php

	secure
		checkout.php

	images
		my_logo.png

	index.php
	product_details.php

 

When I am in "checkout.php" and use this code...

 

<?php	require_once('../components/body_header.inc.php');	?>

 

...my Header appears.

 

But when I try to require the header file using my new DEV_ROOT constant, I can't figure out what the constant and path should be to get it working?!  :'(  :'(

 

Can someone help me understand what to do?

 

Thanks,

 

 

 

Debbie

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.