Home > Backend Development > PHP Tutorial > Tomcat configuration php cannot use $_post, $_get

Tomcat configuration php cannot use $_post, $_get

小云云
Release: 2023-03-20 13:50:02
Original
1550 people have browsed it

When I was in charge of a website using JSP dynamic web technology, I happened to have some functions written in PHP, so I immediately thought of making Tomcat support PHP. Tomcat is also produced by Apache, does it only support JSP? Can I use PHP on Tomcat? After searching online, I quickly got the answer to the first question: Tomcat can support CGI, such as Perl (see attachment for specific settings). But I continue to search, but I have been unable to find a way to let Tomcat use PHP. Generally, I use the method of installing Apache and Tomcat to coexist to build a so-called Web platform that supports PHP+JSP.

Of course, in fact, PHP itself also supports the use of CGI, so I tried it myself (on Windows operating system): First follow the attachment The method is to make Tomcat support CGI, and then change web.xml, and add:

## to the configuration section where the servlet-name is cgi. #

<init-param>
<param-name>executable</param-name>
<param-value>php</param-value>
</init-param>
Copy after login


#And add the PHP installation path to Path, so that Tomcat can run to PHP.exe. After restarting Tomcat, create a new cgi directory under the WEB-INF directory, put the PHP files here, and then use the virtually mapped cgi-bin directory to access these PHPs. document.
But if you don’t make any changes to the PHP file, you may find that there is no output. You need to add a line to the header of the PHP file and output two carriage returns:
echo "\n\n";
The reason is not clear. It may be waiting for Content-type input, or Perl's cgi programming style.
But with this configuration, variables such as $_REQUEST, $_GET, $_POST in PHP (version 4.1.0 or above) cannot be used. QueryString can only be obtained from server variables or environment variables: $_SERVER["QUERY_STRING"], $_ENV["QUERY_STRING"]. Maybe POST submission of the form is not supported... I haven't tried it yet.
Since I am not familiar with Tomcat, these are just minor fixes on the current method. There may be good practices, and I hope you will give me your advice!

Related recommendations:

How to install Tomcat7.0.82 under Linux

Introduction to several class loaders in Tomcat

Detailed explanation of the overall structure of Tomcat

The above is the detailed content of Tomcat configuration php cannot use $_post, $_get. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template