1. One is
<code><a href="<php>echo $_SERVER['HTTP_HOST'].'/home/shop/cate/id/'.$goods['id']</php>" target="_blank">{$goods['name']}</a> </code>
The other one is
<code><a href="<php>echo '/home/shop/cate/id/'.$goods['id']</php>" target="_blank">{$goods['name']}</a> </code>
2. The first one is an absolute path, but the jump page is empty, but if you refresh the page, it will be displayed.
The second one is a relative path, but the content comes out directly after the jump
Excuse me, why is this?
This code is executed under thinkphp,
Is the problem I encountered encountered by all PHP, or is it caused by the unique syntax of thinkphp?
1. One is
<code><a href="<php>echo $_SERVER['HTTP_HOST'].'/home/shop/cate/id/'.$goods['id']</php>" target="_blank">{$goods['name']}</a> </code>
The other one is
<code><a href="<php>echo '/home/shop/cate/id/'.$goods['id']</php>" target="_blank">{$goods['name']}</a> </code>
2. The first one is an absolute path, but the jump page is empty, but if you refresh the page, it will be displayed.
The second one is a relative path, but the content comes out directly after the jump
Excuse me, why is this?
This code is executed under thinkphp,
Is the problem I encountered encountered by all PHP, or is it caused by the unique syntax of thinkphp?
You can’t use $_SERVER['HTTP_HOST']
directly because there is no http://
. Just add http://
before the absolute path
You can find out by right-clicking and viewing the source code. It should be the reason mentioned above