0

I created a basic web server in Java. It can also run php code.

I execute:

php - f <file> 

to get the result and send it back to the client. It works great, however when I want to use the phpinfo(); function, it returns plain text as it is written in the manual too. How can I get the result in HTML format like Apache does?

Thank you!

2
  • This should be the least of your problems. If you're doing this to actually serve web pages you don't have GET/POST parameter processing, no cookies, no custom headers, no session tracking and so on... Commented Oct 11, 2012 at 20:12
  • phpinfo() doesn't output HTML if in CLI (Command Line Interface) mode, and CLI mode is enabled automatically if running from the command line (or the equivalent that you are doing). Maybe execute with the option --disable-cli. Commented Oct 11, 2012 at 20:14

2 Answers 2

5

I'm afraid that's hardcoded in PHP's binary. It detects if it's running an Apache module or the CLI binary. Since you're not invoking the Apache module, it uses the CLI one. From the manual page:

phpinfo() outputs plain text instead of HTML when using the CLI mode.

Sign up to request clarification or add additional context in comments.

2 Comments

And how can I run PHP as for example Apache does? How can I run it as a module of my server?
Not sure you can, really. Unless you use it in CGI mode, the again, not sure how that would work.
1

You might want to try running the file through the php-cgi interface instead (should be an executable named php-cgi or similar).. this is one of the ways you can run php under apache.. (other choice being mod php or fcgi)

Raidence, why would you make a http server with dependencies to apache, you dont get the redundancy in that?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.