php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #34017 CLI php.exe should allow HTML with phpinfo()
Submitted: 2005-08-06 13:52 UTC Modified: 2017-08-23 00:49 UTC
Votes:4
Avg. Score:4.0 ± 0.7
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: csaba at alum dot mit dot edu Assigned:
Status: Analyzed Package: PHP options/info functions
PHP Version: 5.1.0b3 OS: Windows
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-08-06 13:52 UTC] csaba at alum dot mit dot edu
Description:
------------
Using CLI php.exe or php-win.exe on Windows, it is a perfectly reasonable thing to use COM to bring up Internet Explorer.  In fact, it makes a lot of sense to use it strictly as a graphical output (or I/O) mechanism.  Unfortunately, phpinfo() from these versions of php does not allow the option of outputting with HTML.  Since COM is now supported in PHP5, it seems that wanting CLI output of phpinfo() to go to a browser will become more common.

I would therefore like to suggest that either:
(1) phpinfo() respect the html_errors setting or
(2) phpinfo() take a second, optional argument, which, if supplied and non false, would lead to phpinfo() outputting HTML for CLI php and withholding the HTML for non CLI php.

Thanks,
Csaba Gabor from Vienna

Note.  Running the attached code with php-cgi.exe will illustrate what I would like: formatted phpinfo() appearing in IE.  But I'd like it to work with php.exe and php-win.exe, too.

Reproduce code:
---------------
<?php
    // bring up IE (from CLI php.exe)
    $ie = new COM("InternetExplorer.Application");
    $ie->Navigate("about:blank");
    $ie->visible = true;

    // try to get formatted phpinfo();
    ini_set("html_errors", "1");
    ob_start();
    phpinfo();
    $phpinfo = ob_get_contents();
    ob_end_clean();

    // output it to IE
    $ie->Document->Write($phpinfo);
?> 

Expected result:
----------------
I would expect to get formatted phpinfo() with the supplied code example, but I only get raw phpinfo().


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-12-30 22:59 UTC] cmb@php.net
-Package: Feature/Change Request +Package: PHP options/info functions
 [2017-08-23 00:49 UTC] kalle@php.net
This is a plain limitation within the SAPI struct, that sets phpinfo_as_text to 1 for some SAPIs and there is no way to directly control it. I don't think we should let allow userland to change this.

What you can do is to invoke php-cgi.exe and strip the headers and then put the output in a HTML file.

You can do something like (not tested):

$tmp = tmpfile();
file_put_contents($tmp, '<?php phpinfo(); ?>');

$phpinfo = `php-cgi -q "$tmp"`;

fclose($fmp);
 [2017-08-23 00:49 UTC] kalle@php.net
-Status: Open +Status: Analyzed
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC