php获取当前页面【不】完整url地址,请看代码
function parseurl($url, $text, $scheme) {
global $_G;
if(!$url && preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.)[^\[\"']+/i", trim($text), $matches)) {
$url = $matches[0];
$length = 65;
if(strlen($url) > $length) {
$text = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3));
}
return '<a href="'.(substr(strtolower($url), 0, 4) == 'www.' ? 'http://'.$url : $url).'" target="_blank">'.$text.'</a>';
} else {
$url = substr($url, 1);
if(substr(strtolower($url), 0, 4) == 'www.') {
$url = 'http://'.$url;
}
$url = !$scheme ? $_G['siteurl'].$url : $url;
return '<a href="'.$url.'" target="_blank">'.$text.'</a>';
}
}
改后。
function parseurl($url, $text, $scheme) {
global $_G;
if(!$url && preg_match("/((https?|ftp|gopher|news|telnet|rtsp|mms|callto|bctp|thunder|qqdl|synacast){1}:\/\/|www\.)[^\[\"']+/i", trim($text), $matches)) {
$url = $matches[0];
$length = 200;
if(strlen($url) > $length) {
$text = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3));
}
return '<a href="http://localhost/go.php?url='.(substr(strtolower($url), 0, 4) == 'www.' ? 'http://'.$url : $url).'" target="_blank">'.$text.'</a>';
} else {
$url = substr($url, 1);
if(substr(strtolower($url), 0, 4) == 'www.') {
$url = 'http://'.$url;
}
$url = !$scheme ? $_G['siteurl'].$url : $url;
return '<a href="http://localhost/go.php?url='.$url.'" target="_blank">'.$text.'</a>';
}
}
我在GO.PHP跳转代码里加
<script>
function goURL( goUrlStr ) {
if ( typeof(goUrlStr) != 'undefined') {
var isIe=(document.all)? true : false;
if(isIe) {
var linka = document.createElement('a');
linka.href = goUrlStr;
document.body.appendChild(linka);
linka.click();
} else {
window.location = goUrlStr;
}
}
return true;
}
</script>
<body><script>goURL('这个是地址位置我改怎么加http://localhost/go.php?url=后面的地址在这呀。');</script><body>
要不然http://localhost/go.php?url=在显示后面的地址 会出现重向循环。只有要http://localhost/go.php?url=后面的地址了。
高手们谢谢你们了
下面是完整的地址获取
<script>
function goURL( goUrlStr ) {
if ( typeof(goUrlStr) != 'undefined') {
var isIe=(document.all)? true : false;
if(isIe) {
var linka = document.createElement('a');
linka.href = goUrlStr;
document.body.appendChild(linka);
linka.click();
} else {
window.location = goUrlStr;
}
}
return true;
}
</script>
<body><script>goURL('<?php
function get_page_url(){
$url = (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') ? 'https://' : 'http://';
$url .= $_SERVER['HTTP_HOST'];
$url .= isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
return $url;
}
$target = get_page_url();
header("location:".$target);
?>');</script><body>
获取后的地址http://localhost/go.php?url=http://redirect.simba.taobao.com/rd?w=aitaobao_auctionlist&f=http%3A%2F%2Fai.taobao.com%2Fauction%2Fidetail.htm%3Fe%3D9yJqNV6xpsTghojqVNxKsXYlGzf9L3QKAdcPAzm7QvSLltG5xFicOVsrMD406QbSxN35oEuRTJfz8%252FzzUUAa8ZxtFGeD4d%252F1L7cKmKx7yws%253D%26ptype%3D100016%26from%3Daitaobao%23app_pvid%3D200_10.246.41.109_308_1402996372125&k=b9ae9a9259ca89f8&c=un&b=3_4&p=mm_0_0_0&pvid=100_10.238.192.12_24338_1403003417786149925
我想去掉http://localhost/go.php?url=自动显示后面的地址怎么改呀。,
相关推荐
php获取当前页面完整URL地址
使用PHP编写程序的时候,我们常常想要获取当前页面的URL。下面提供一个用于获取当前页面URL的函数以及使用方法: 示例一: <?php // 说明:获取完整URL function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":
PHP获取当前页面完整URL的方法
在大家在使用PHP编写程序的时候,我们常常想要获取当前页面的URL。下面就给大家分享了PHP获取当前页面完整URL的方法,文中还给出了如获取域名或主机地址、获取网页地址和包含端口号的完整url等的方法,有需要的朋友们可以参考借鉴,下面来一起看看吧。
php 获取完整url地址
主要是获取到地址栏的一些信息,域名,端口参数等 复制代码 代码如下: <?php //获取域名或主机地址 echo $_SERVER[‘HTTP_HOST’].”<br>”; //获取网页地址 echo $_SERVER[‘PHP_SELF’].”<br>”; //获取网址参数 echo $_SERVER[“QUERY_STRING”].”<br>”; //来源网页的详细地址 echo $_SERVER[‘HTTP_REFERER’].”<br>”; ?> php 获得当前的脚本网址(只有路径) 复制代码 代码如下: function GetCurUrl() { if(!empty($_SER
WordPress获取当前页面URL地址的方法
主要为大家介绍了WordPress获取当前页面URL地址的方法,给出了WordPress原生方法与自定义方法,是非常实用的技巧,需要的朋友可以参考下
PHP获取当前页面完整URL的实现代码
本篇文章是对利用PHP获取当前页面完整URL的实现代码进行了详细的分析介绍,需要的朋友参考下


