-1
我想将以下PHP代码转换为JavaScript。将PHP代码转换为JavaScript
<body>
<?php
$opts = array('http'=>array('method'=>"GET",
'header'=>"User-agent: CUSTOM_USER_AGENT\r\n"));
$context = stream_context_create($opts);
$file = file_get_contents("http://example.com/file1", false, $context);
///open http://example.com/file1 with CUSTOM_USER_AGENT
$pattern = "/^Location:\s*(.*)$/i";
$location_headers = preg_grep($pattern, $http_response_header);
//find url where this redirects to
echo $location_headers
?>
</body>
欢迎来到SO。请访问[帮助],看看有什么和如何问。在这种情况下,请添加努力,至少预期的行为和缺少分号 – mplungjan
尝试添加一些更多的描述您的问题..! – Seeker
那就是所有我只是想将此PHP代码转换为JavaScript。 –