Cannot get value from define function ?

hello everyone,
I try to get value from define function (core php)

I explain my problem :
I have 3 pages.
- index.php
- config.php
- footer.php

index.php :
i include the config.php file ( see code snippet )

config.php :
declare the constant SERVER_WEB by using define function. ( see code snippet )

footer.php : ( see code snippet )
try to show value of constant SERVER_WEB. and this is what i get :

no error is reporting from php.
thanks for all,

//*************** index.php : 
//*************** config.php : 
//*************** footer.php : 

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

error_reporting(E_ALL) may not be enough if display_errors if turned off, unless you're looking at the web server's log file.

Add ini_set('display_errors', true) to make sure errors are showing.

You could have a wrong include for instance, or some other errors that are not displayed.
beatboxradioAuthor Commented:
ok i've added new things...

into index.php :
ini_set('display_errors', true);

look into logs of apache and php, and no error is showing.

i will add a new information :
when i call the page footer.php, i use this :

the page is called successfully but the variable SERVER_WEB has no value.

also into php.ini, this is what i get :
allow_url_fopen = On
allow_url_include = On

display_errors = On
display_startup_errors = On
log_errors = On
error_reporting = E_ALL & E_STRICT

Double check the config.php you're loading is really the one you expect. For instance is it really in the includes/ sub-folder etc...

An easy way to do check this is to intentionally create a parsing error in the config.php file.

Also make sure the config.php file doesn't overwrite error_reporting set in the index.php.

On a side note, I advise you to always use <?php instead of <? and use <?php echo instead of <?=

Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

beatboxradioAuthor Commented:
ok, i change again my things.

really strange...
//************ index.php
echo TEST;
//******** HTML_PATH works here, value is html/
//**************** footer.php
<?php echo TEST; ?>
//********** value of TEST show in index.php
//********** value of TEST show in footer.php
/** TEST

Open in new window

Roger BaklundCommented:
Maybe short_open_tag is disabled on your server?

In your last example, how is the footer.php called? Directly in the browser, or included from index.php?
The value of an undefined constant will be the name of the costant, i.e. if you did not define TEST, the output of echo TEST; should be "TEST". It should also give a warning about undefined constant.

You can use the defined() function to check if a constant is definied:
beatboxradioAuthor Commented:
for CXR :
the short_open_tag was ON.

but  I found something :

i call footer.php like that :

<? include(HTML_PATH.'footer.php'); ?>
( where HTML_PATH = http://localhost/beatboxradio_v6/html/ )

and like this way, the constant into footer.php TEST doesn't work.

if I replace HTML_PATH by subfolder " html/ " =
everything works fine.

i don't know why by using HTML_PATH the constant don't have the value because
the footer.php file load successfully by using HTML_PATH.


beatboxradioAuthor Commented:
for CXR :
i call footer.php into index.php like :
<? include(HTML_PATH.'footer.php'); ?>

and TEST constant was defined into index.php  like :

Roger BaklundCommented:
Try executing this:

echo phpversion().'<br />';
echo 'allow_url_fopen='.(ini_get('allow_url_fopen') ? 'on':'off').'<br />';
echo 'allow_url_include='.(ini_get('allow_url_include') ? 'on':'off').'<br />';

Including a file using http:// is only allowed if the version is later than 4.3 and both allow_url_* settings are on.

A safer way to include is using $_SERVER['DOCUMENT_ROOT']:


Open in new window

beatboxradioAuthor Commented:
this is what i got :


thx for your new way to include !
Roger BaklundCommented:
Using urls in the include path is for including code from remote servers. Using localhost won't work at all on my windows box, don't know why. I get a timeout. Apache error log says:

"failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond."

...this is when php tries to connect to localhost over port 80...!?

As a consequence, I can not recreate your situation.
beatboxradioAuthor Commented:
ok, I found a solution :

"When you include it using a URL as above, the file is served from the
webserver which parses the php script as it has a php extension. With
the other extensions, the php code isn't parsed. Try looking at the
URL with a browser and you'll see what I mean.

Your include path should be a physical path to the file e.g:
include ('/usr/local/htdocs/includes/includes.php');"

by using, the physical path, everything works fine !

thx for all !

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.