Home > Backend Development > PHP Tutorial > Why does the relative path jump succeed but the absolute path jump fails? (see code for details)

Why does the relative path jump succeed but the absolute path jump fails? (see code for details)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-04 09:19:07
Original
1581 people have browsed it

1. One is

<code><a href="<php>echo $_SERVER['HTTP_HOST'].'/home/shop/cate/id/'.$goods['id']</php>" target="_blank">{$goods['name']}</a>
</code>
Copy after login
Copy after login

The other one is

<code><a href="<php>echo '/home/shop/cate/id/'.$goods['id']</php>" target="_blank">{$goods['name']}</a>
</code>
Copy after login
Copy after login

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 template writing method of thinkphp.
Is the problem I encountered encountered by all PHP, or is it caused by the unique syntax of thinkphp?

Reply content:

1. One is

<code><a href="<php>echo $_SERVER['HTTP_HOST'].'/home/shop/cate/id/'.$goods['id']</php>" target="_blank">{$goods['name']}</a>
</code>
Copy after login
Copy after login

The other one is

<code><a href="<php>echo '/home/shop/cate/id/'.$goods['id']</php>" target="_blank">{$goods['name']}</a>
</code>
Copy after login
Copy after login

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 template writing method of 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

Related labels:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template