gpt4 book ai didi

php - 如何将urlencode包含到源代码中?

转载 作者:行者123 更新时间:2023-11-28 03:54:10 24 4
gpt4 key购买 nike

我正在尝试使用

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

但我不知道如何添加到我的源代码中。我需要对 URL 进行编码才能使用

file_get_contents

我的代码:

     <script class="ccscript" src="https://code.jquery.com/jquery-3.2.0.min.js" type="text/javascript"></script>
<title>GET URL IMAGE</title>
<div style="width:1265px;margin:auto;">
<?php

if(isset($_POST['ok'])){
$link = $_POST['link'];
$source = file_get_contents($link);
if(strpos($source,'example.org')!==false){
$pa = '#"\s><a\shref=\"(.*?)\".*?>#s';
}else{
$pa = '#<img\sclass.*?src=\"(.*?)\"\/>#s';
}
preg_match_all($pa, $source, $matches);
echo '<div style="float:right"><textarea class="text" cols="110" rows="50">';

foreach($matches[1] as $item) //GET URL 1,IMG TAG = 0
{
if(strpos($item,'http://')!==false)
{
echo $item."\r\n";
}
}
echo '</textarea></div>';
}
?>
<div style="float:left;width:210px;margin-right:15px">
<form action="get.php" method="POST">
<input type="text" name="link" size="60" />
<input type="submit" name="ok" />
</form>

示例网址:http://www.example.org/%E5%9F/

当我尝试获取图片 url 时,我得到了这个

failed to open stream: HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable

我想我需要使用 urlencode 才能获取图片 url

最佳答案

试试这个:

$source = file_get_contents(urlencode($link));

关于php - 如何将urlencode包含到源代码中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43562916/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com