문제

For example in my view.jsp:

<img src="<%=request.getContextPath() %>/images/helloWorld.jpg" />
<?php echo "Hello World!"; ?>

or for example I want to get the ContextPath inside a PHP file (index.php). How can I accomplish that?

올바른 솔루션이 없습니다

다른 팁

You can get this information via PHP without calling out to JSP. To get the location of the current request, use

$_SERVER['REQUEST_URI'];

This will return the complete URI, including the script name. If you want only the directory structure and not the trailing script name, you can use trim() to remove the excess. For convenience, note that the script name is stored here:

$_SERVER['SCRIPT_NAME'];

For additional information and examples, see https://coderwall.com/p/gdam2w

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top