dongxidui1227 2010-07-19 16:55
浏览 6
已采纳

将特殊字符插入到Web地址的字符串中(PHP问题)

I posted this question last week, but I wasn't very clear on what was needed. So I'm reposting right now.

I have a string stored in a database, which looks something like this:

<5u79cfda 4d01ga3a 11c833f9 7b52df2a 7g210252 e21b01fa a73d3463 9ge0e412>

I'm trying to insert this into a web address, but needs to be encoded properly for it to work. I'm running a query to obtain the script:

$result = mysql_query("SELECT cPushID FROM tblUsers WHERE intUserID='20' AND Length(cPushID) > 70");

$pid = mysql_fetch_row($result);

Then trying to insert it into this web address to be executed:

file_get_contents("http://domain/test.php?msg='Test!'&to=$pid");

How do I properly insert this string into the web address so it will be read properly upon execution.

Thanks for your help.

  • 写回答

3条回答 默认 最新

  • duanci5913 2010-07-19 16:58
    关注

    How about urlencode?

    $encoded = urlencode($some_string");
    

    Pass that encoded string to file_get_contents

    If you ever need to decode it, use urldecode()

    http://php.net/manual/en/function.urlencode.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错