Home > Q&A > body text
I originally learned java by using <%=request.getContextPath()%> to get the site root directory, but now I’m confused when learning php
java is
< ;a href="<%=request.getContextPath()%>/html/main/main.jsp">Homepage</a></span>
How to write php
寻觅 beyond2017-10-21 12:07:02
You can use $_SERVER['DOCUMENT_ROOT'] to get
No, what you get is the project address of the server, not the root directory of the URL.
Reply to Labmem No.000: Then you can just use $_SERVER['HTTP_HOST'] to obtain the domain name. The domain name is the root directory of the site.
ringa_lee2017-10-21 09:36:43
PHP has a magic constant __FILE__ that can be obtained