这是我发现用于编写jQuery bookmarklet的脚本,我已经添加了三行代码.问题是jQuery代码有很多引号(对于选择器),因为我必须将bookmarklet放在href ="javascript:code"中,所有内容都会被href的双引号弄乱.这是我的代码看起来像,我试图逃避双引号,在许多方面,但没有一个工作.有办法解决这个问题吗?
<a href="javascript:(function(){
// the minimum version of jQuery we want
var v = '1.3.2';
// check prior inclusion and version
if (window.jQuery === undefined || window.jQuery.fn.jquery < v) {
var done = false;
var script = document.createElement('script');
script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/' + v + '/jquery.min.js';
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
done = true;
initMyBookmarklet();
}
};
document.getElementsByTagName('head')[0].appendChild(script);
} else {
initMyBookmarklet();
}
function …Run Code Online (Sandbox Code Playgroud) 我对curlinit()和close()函数感到困惑。我想知道在以下每种情况下何时应该关闭curl 句柄:
1. 使用单个句柄获取“单个”URL,并具有不同的选项。例如:
$curl=curl_init('google.com');
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,true);
curl_exec($curl);
Run Code Online (Sandbox Code Playgroud)
现在我想将 FOLLOWLOCATION 设置为 false。我应该做curl_close($curl),并从头开始做所有事情,或者只是设置选项并再次执行它,如下所示:
curl_setopt($curl,CURLOPT_FOLLOWLOCATION,false);
curl_exec($curl);
Run Code Online (Sandbox Code Playgroud)
2.使用单个句柄获取“多个”URL。例如:
$curl = curl_init('google.com');
curl_exec($curl);
Run Code Online (Sandbox Code Playgroud)
现在我想要访问 stackoverflow.com。我应该关闭句柄并从头开始,还是可以设置另一个 URL 而不关闭句柄。像这样:
$curl = curl_init('stackoverflow.com');
curl_exec($curl);
Run Code Online (Sandbox Code Playgroud)
3.使用多个句柄获取多个URL。这是我的代码:
$CONNECTIONS=10;
$urls=fopen('urls.txt','r');
while(!feof($urls))
{
$curl_array=array();
$curl=curl_multi_init();
for($i=0;$i<$CONNECTIONS&&!feof($urls);$i++)
//create 10 connections unless we have reached end of file
{
$url=fgets($urls); //get next url from file
$curl_array[$i]=curl_init($url);
curl_multi_add_handle($curl,$curl_array[$i]);
}
$running=NULL;
do
{
curl_multi_exec($curl,$running);
}while($running>0);
for($i=0;$i<$CONNECTIONS;$i++)
{
$response=curl_multi_getcontent($curl_array[$i]);
curl_multi_remove_handle($curl,$curl_array[$i]);
curl_close(($curl_array[$i]));
}
curl_multi_close($curl);
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的:获取每个单个句柄的内容后,我将从多句柄中删除该句柄,关闭单个句柄,然后在 for 循环后关闭多句柄。这种做法是否正确,还是我过度闭合了手柄?
谢谢
我已经阅读了许多有关文件权限的教程,但他们只说“如果您不希望其他人写文件,请将其设置为xxx ...”。
但是在虚拟主机中,谁是谁?只有一个Web服务器(Apache)以及php和mysql等程序。没有“其他用户”。教程说,apache被认为是“公开的”。但我有一个php脚本,它会获取一个上传的文件,并将其放在“下载”目录中。我将该目录的权限设置为744。这意味着组和公共应该只能“读取”并且所有者拥有完全访问权限。我希望我上传的文件不会传输到该目录,因为没有对“ public”的“写”权限。但是文件在那里。更令我困惑的是,当我尝试下载文件时,出现了“禁止”错误。我希望能够下载该文件,因为公众拥有“读取”权限。