Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Consider this environment:

$ cat .htaccess
AddType application/x-httpd-php .php .html
SetEnv Foo Bar

$ cat test.php
<?php
echo "Hello: ";
echo $_SERVER['Foo'];
echo $_ENV['Foo'];
echo getenv('Foo');
?>

$ cat test.html
<?php
echo "Hello: ";
echo $_SERVER['Foo'];
echo $_ENV['Foo'];
echo getenv('Foo');
?>

This is the output of test.php:

Hello BarBarBar

This is the output of test.html:

Hello 

Why might that be? How might I fix it?

Here is phpinfo.php: http://pastebin.com/rgq7up61

Here is phpinfo.html: http://pastebin.com/VUKFNZ36

If anyone knows where I can host a real webpage instead of just the HTML for one, please let me know and I'll move the content to there. Thanks.

share|improve this question
    
That is kinda weird. What happens if you put a phpinfo(); in the .html file? Do you see any differences from what you see in a .php file? Are you sure your Apache configuration isn't adjusting the configuration with a <files> directive or anything? –  Zoredache Aug 7 '12 at 22:06
    
I've tried to reproduce your problem but could not : Output of test.html is same as test.php Hello: BarBar. And I start wondering why one bar is missing. –  Eric DANNIELOU Aug 7 '12 at 22:18
    
Thank, Zoredache. In fact I see many more environment variables for the .html files than for the .php files. However, the Foo variable is only available in the .php files. I don't see any difference in the configuration section, though. –  dotancohen Aug 8 '12 at 5:42
    
@EricDANNIELOU: It is not unusual that one or two of the methods won't work. I is unusual that .html and .php files will show them differently, though. –  dotancohen Aug 8 '12 at 5:43
    
I agree. But without being able to reproduce your problem, I won't be able to help a lot. Could you post full apache and php config (change or hide some values if needed). Would you have phpinfo and most softare/os versions? –  Eric DANNIELOU Aug 8 '12 at 8:20
show 1 more comment

1 Answer

the difference is visible in the block:

Environment 

there in the html-version all variables are set in the old global form:

$HTTP_HOST, $HTTP_USER_AGENT, etc.

and in the new form too:

$_SERVER["HTTP_HOST"], $_SERVER["HTTP_USER_AGENT"], ...

in the php version they are set only in the new form. it seems like the html-version uses another php.ini.

also i see the variable

$_SERVER["ORIG_SCRIPT_FILENAME"]    ="/var/www/cgi-bin/cgi_wrapper/cgi_wrapper"

maybe the html-file is parsed with the

/etc/php5/cli/php.ini
share|improve this answer
    
Thank you. Due to the AddType declaration in .htaccess I think that both the .html and .php files should be using the same configuration files. I will ask the server admin, though. Thank you Rubo. –  dotancohen Sep 17 '12 at 15:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.