请教一个问题。http://bbs.csdn.net/posts/394378416跳转到http://bbs.csdn.net/topics/39044629

WBOY
Lepaskan: 2016-06-23 13:46:10
asal
1072 orang telah melayarinya

如题,csdn当中回复的链接是http://bbs.csdn.net/posts/394378416,打开跳转到了http://bbs.csdn.net/topics/390446295?page=1#post-394378416。想请教下这个是如何实现的。谢谢了。最好能够提供稍微详细一点思路。。感激不尽


回复讨论(解决方案)

http://bbs.csdn.net/topics/390446295?page=1#post-394378416
这个请求是 304 Not Modified
感觉是把它当成静态资源了,这样可以减少服务器压力吧。。

print_r(get_headers('http://bbs.csdn.net/posts/394378416'));
Salin selepas log masuk
Salin selepas log masuk

Array
(
[0] => HTTP/1.1 302 Found
[1] => Content-Type: text/html; charset=utf-8
[2] => Connection: close
[3] => Status: 302
[4] => X-Powered-By: Phusion Passenger (mod_rails/mod_rack)
[5] => Location: http://bbs.csdn.net/topics/390446295?page=1#post-394378416
[6] => Cache-Control: no-cache
[7] => Server: nginx/1.2.4 + Phusion Passenger (mod_rails/mod_rack)
[8] => X-UA-Compatible: IE=Edge,chrome=1
[9] => HTTP/1.1 200 OK
[10] => Content-Type: text/html; charset=utf-8
[11] => Connection: close
[12] => Vary: Accept-Encoding
[13] => Status: 200
[14] => X-Powered-By: Phusion Passenger (mod_rails/mod_rack)
[15] => ETag: "231291d30689ba22a7779cff3dc0ada1"
[16] => Cache-Control: max-age=0, private, must-revalidate
[17] => Set-Cookie: _csdn_newbbs_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWY5NmFhN2FkNTE4YzdlZDJhYjFlNjIyMDAzNjIwNDE3BjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMUl5Z3BQS2tFRkwxOWlUU3JkWFBCV2l0ZFVUcWVIdDdwcHJhNExVVnBkQVU9BjsARg%3D%3D--60a16fb96488bbb1b58fa68660313d3427bc5735; path=/; HttpOnly
[18] => Set-Cookie: UserName=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT
[19] => Set-Cookie: UserInfo=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT
[20] => Server: nginx/1.2.4 + Phusion Passenger (mod_rails/mod_rack)
[21] => X-UA-Compatible: IE=Edge,chrome=1
)

应该很清楚了吧?

print_r(get_headers('http://bbs.csdn.net/posts/394378416'));
Salin selepas log masuk
Salin selepas log masuk

Array
(
    [0] =>  HTTP/1.1 302 Found
    [1] => Content-Type: text/html; charset=utf-8
    [2] => Connection: close
    [3] => Status: 302
    [4] => X-Powered-By: Phusion Passenger (mod_rails/mod_rack)
    [5] =>  Location: http://bbs.csdn.net/topics/390446295?page=1#post-394378416
    [6] => Cache-Control: no-cache
    [7] => Server: nginx/1.2.4 + Phusion Passenger (mod_rails/mod_rack)
    [8] => X-UA-Compatible: IE=Edge,chrome=1
    [9] => HTTP/1.1 200 OK
    [10] => Content-Type: text/html; charset=utf-8
    [11] => Connection: close
    [12] => Vary: Accept-Encoding
    [13] => Status: 200
    [14] => X-Powered-By: Phusion Passenger (mod_rails/mod_rack)
    [15] => ETag: "231291d30689ba22a7779cff3dc0ada1"
    [16] => Cache-Control: max-age=0, private, must-revalidate
    [17] => Set-Cookie: _csdn_newbbs_session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWY5NmFhN2FkNTE4YzdlZDJhYjFlNjIyMDAzNjIwNDE3BjsAVEkiEF9jc3JmX3Rva2VuBjsARkkiMUl5Z3BQS2tFRkwxOWlUU3JkWFBCV2l0ZFVUcWVIdDdwcHJhNExVVnBkQVU9BjsARg%3D%3D--60a16fb96488bbb1b58fa68660313d3427bc5735; path=/; HttpOnly
    [18] => Set-Cookie: UserName=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT
    [19] => Set-Cookie: UserInfo=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT
    [20] => Server: nginx/1.2.4 + Phusion Passenger (mod_rails/mod_rack)
    [21] => X-UA-Compatible: IE=Edge,chrome=1
)

应该很清楚了吧?



嗯,再请教个问题。。如何效率高一点的获取到该条评论在第几页呢

跟分页一样
可以这样做
1、取得的全部评论到数组
2、取得该评论在全部评论的位置
3、计算隶属页号
并不存在所谓“高效”算法

xue xi le~!









--- 跟人签名 ----------------
高价收药、收药、北京收药:
http://www.woshouyao.com/index.php

sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan