php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80674 getenv("COMPUTERNAME") gets no result anymore
Submitted: 2021-01-27 07:22 UTC Modified: 2021-01-28 15:26 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: info at sperlingprog dot com Assigned: cmb (profile)
Status: Not a bug Package: Unknown/Other Function
PHP Version: 8.0.1 OS: Windows 10 prof
Private report: No CVE-ID: None
 [2021-01-27 07:22 UTC] info at sperlingprog dot com
Description:
------------
getenv("COMPUTERNAME") gets no result anymore


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-27 07:38 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2021-01-27 07:38 UTC] requinix@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


 [2021-01-27 14:25 UTC] info at sperlingprog dot com
-Status: Feedback +Status: Open
 [2021-01-27 14:25 UTC] info at sperlingprog dot com
$PCNAME = strtoupper(getenv("COMPUTERNAME"));

getenv returns no result or returns a empty string

expected: the name of Windows PC (COMPUTERNAME) 

the same line in php 7 works as expected
 [2021-01-28 11:01 UTC] cmb@php.net
-Status: Open +Status: Feedback
 [2021-01-28 11:01 UTC] cmb@php.net
Hmm, works for me with the CLI Sapi.  Which SAPI/Webserver do you
use?  Also make sure to check the output of

    var_dump(getenv("COMPUTERNAME"))

Does you COMPUTERNAME contain non-ASCII characters?
 [2021-01-28 12:09 UTC] info at sperlingprog dot com
-Status: Feedback +Status: Open
 [2021-01-28 12:09 UTC] info at sperlingprog dot com
in phpinfo(); is no entry 'COMPUTERNAME' under Environment

var_dump(getenv("COMPUTERNAME")) => bool(false)

apache 2.4 php8 32 bit
ScriptAlias /php8 "C:/web/php8_32bit"
<Directory "C:/web/php8_32bit">
    AllowOverride None
    Options None
    Require all denied
    <Files "php-cgi.exe">
        Require all granted
    </Files>
</Directory>

<Directory "C:\web\Apache24\htdocs\burz_auftraege">
    UnsetEnv PHPRC
    <FilesMatch "\.php$">
        SetHandler application/x-httpd-php8
        Action application/x-httpd-php8 "/php8/php-cgi.exe"
    </FilesMatch>
</Directory>

my PCNMAE is 'SPERLINGPROG'
__________________________________________________
with php7 ( same apache ) it works but over:
LoadModule php7_module "C:\web\php7_32bit\php7apache2_4.dll"
 [2021-01-28 13:01 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-01-28 13:01 UTC] cmb@php.net
Thanks for the swift reply!

> with php7 ( same apache ) it works but over:
> LoadModule php7_module "C:\web\php7_32bit\php7apache2_4.dll"

Ah, so this is not a behavioral change in PHP 8, but rather a
behavioral difference between running PHP with Apache as module
and as (F)CGI, respectively.  It is actually not even a bug
regarding PHP, but rather a configuration issue of Apache.  Please
consult the respective Apache documentation and/or support
channels.

By the way, did you deliberately switch to (F)CGI?
 [2021-01-28 14:52 UTC] info at sperlingprog dot com
... By the way, did you deliberately switch to (F)CGI? ...

I needed different versions of php for different directorys. AND I found this way to solve.

Is there a better way? Or why du U ask?
 [2021-01-28 15:26 UTC] cmb@php.net
> I needed different versions of php for different directorys.

Ah, okay, makes sense.  I wondered whether you had issues setting
up PHP 8.0 as Apache module.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun May 22 08:05:44 2022 UTC