dph6308 2013-12-18 19:34
浏览 43
已采纳

将php文本字符串添加到代码中

I have so stupid issue which I just can't resolve now and I need it so much..

So here's the code:

 $siteURL = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/';

$bookmarklet = 'javascript:document.location.href=\'' . $siteURL . '?url=\'+escape(document.location.href)';

it takes things from url, like "domain.com/?url=things"

I need the code to add http:// before "things"

I've tried adding $bookmarklet = 'http://'. $bookmarklete and changing it in various ways but it didn't helped.

Please help me guys!

  • 写回答

1条回答 默认 最新

  • dongzhenju3015 2013-12-18 21:30
    关注

    It looks like line 72 of your full code is using the query string url from the page url going to the variable $url

    $url = $_GET['url'];
    

    try changing to:

    $url = 'http://'.$_GET['url'];
    

    Are you trying to change this bit of the code? You question is not very clear on what needs to be changed (what is it now Vs what you want it to be) or where your example url is coming from and where in your $bookmarklet string the 'url' part needs to go... if anywhere?

    Your actual $bookmarklet string looks ok to me although as I said before it is not used in the script so you can assign it anything you like and I can't imagine it making any difference!

    You could tidy the $bookmark string to this:

    $bookmarklet = "javascript:location.href='$siteURL?url='+encodeURI(location.href)";
    

    encodeURI() is the newer replacement for escape()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?