[英]Php coding advice
I want to transform this code in fsockopen: 我想在fsockopen中转换此代码:
$z = $_GET['z'];
$z = str_replace(' ', '%20', $z);
if("$z")
{
$file = file("http://example.com/$z");
}else{
$file = file("http://example.com/main/");
}
$file = @implode("", $file);
$file = str_replace('/main/', '?z=main/', $file);
echo $file;
can u help me ? 你能帮我吗 ?
Try this : 尝试这个 :
function replaceDomain($url = null){
$parts = explode('.com/', $url);
return $parts[0].'.com/index.php?z='.$parts[1];
}
$url = "http://example.com/downloads/programs/100";
echo replaceDomain($url);
OUTPUT : 输出:
http://example.com/index.php?z=downloads/programs/100
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.