Jump to content

Root include and passing variable


liquinas

Recommended Posts

Hello again!

 

I'm trying to pull an include on all files on a site. I'm trying to get all files in the root directory as well as all files inside folders pull the same file. I came up with this:

 

<?php
include('http://'.$_SERVER['SERVER_NAME'] . '/inc/php_header.php'); ?>
<html>
<head>123</head>
<body>

The phone number is <?php echo "$phone"; ?>
</body>
</html>

 

All that's in the include file is this:

 

<?php $phone = "555-555-5555"; ?>

 

Problem is that $phone won't echo, however it does just fine with a regular include line: include('inc/php_header.php');

 

Is there a better way to do this? Am I doing something wrong? Any help appreciated.

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/117640-root-include-and-passing-variable/
Share on other sites

Thanks for the reply DarkWater. If I use include($_SERVER['DOCUMENT_ROOT'] . 'inc/php_header.php');

It goes to htdocs which isn't really the root dir (site pool). Which is why I can use include('../inc/php_header.php'); because the files in the root dir then try to pull from one level above.

 

Any ideas?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.