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()

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

报告相同问题?

悬赏问题

  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名