假设我有这段代码:
$dom = new DOMDocument();
@$dom->loadHTMLFile('sample.html');
$xp = new DOMXPath($dom);
$result = $xp->query("//input[@id='honey']");
Run Code Online (Sandbox Code Playgroud)
如何仅获取value
第一个结果的属性内容,因为我只期望一个结果(不使用foreach循环).我尝试var_dump
了结果,但它不能.我也试过current($result)->getAttribute('value')
但没有运气.
我有一个数据透视表,当然每一行都将包含在查询中:
mysql> select * from blog_posts as bp
join blog_joins as bj
on bj.post_id=1
and bj.taxonomy_id=10
and bj.type = 1;
Run Code Online (Sandbox Code Playgroud)
这是我的表结构:
是否建议为每一列做一个索引?如果没有,为什么以及你会推荐什么?
mysql > alter table blog_joins add index pid (post_id);
mysql > alter table blog_joins add index tid (taxonomy_id);
mysql > alter table blog_joins add index tp (type);
Run Code Online (Sandbox Code Playgroud) 我正在尝试做的是将所有请求路由/rdr/extern_url
到extern_url
通过我的Web服务器重定向,而不是通过PHP进行.
location /rdr {
rewrite ^/rdr/(.*)$ $1 permanent;
}
Run Code Online (Sandbox Code Playgroud)
这有什么问题,如果我访问http://localhost/rdr/http://google.com
我的浏览器告诉我:
Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.
Run Code Online (Sandbox Code Playgroud)
如何正确重定向?
让我们说一个例子我有一个类:
//no namespace
class User {
//...
}
Run Code Online (Sandbox Code Playgroud)
我有一个变量:
$model = 'User';
Run Code Online (Sandbox Code Playgroud)
new User
当我当前在命名空间中时,如何实例化?
new $model
当我不在命名空间时工作.但是,如果我在命名空间中并且User
不在命名空间中,该怎么办?
这样的东西不起作用:
namespace Admin;
class Foo {
function fighter($model)
{
return new \$model;
// syntax error, unexpected '$model'
}
}
}
Run Code Online (Sandbox Code Playgroud) 这是我第一次学习python,我继续尝试从这篇博客文章中进行线程化.问题是它似乎已经过时了:
import time
from threading import Thread
def myfunc(i):
print ("sleeping 5 sec from thread %d" % i)
time.sleep(5)
print ("finished sleeping from thread %d" % i)
for i in range(10):
t = Thread(target=myfunc, args=(i,))
t.start()
Run Code Online (Sandbox Code Playgroud)
如何在不出现此错误的情况下运行此代码:
$ python helloworld.py
Traceback (most recent call last):
File "helloworld.py", line 1, in <module>
import threading
File "c:\Documents and Settings\Hermione\learningPython\threading.py", line 2, in <module>
from threading import Thread
ImportError: cannot import name Thread
Run Code Online (Sandbox Code Playgroud)
threading.py
由于我已经删除了该文件(并且它一直出现!!)和一个神秘的__PyCache__
文件夹,因此我在那里也很奇怪.
我有一个典型的形式:
<form action="" accept-charset="utf-8" method="post">
<textarea name="content"></textarea>
</form>
Run Code Online (Sandbox Code Playgroud)
和一个不在形式内的元素:
<input type="password" name="password">
Run Code Online (Sandbox Code Playgroud)
提交表单时如何在表单中添加密码值?
$('form').submit(function(){
//hmmm
});
Run Code Online (Sandbox Code Playgroud) $name = 'John Doe';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$age = 16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$address = 'Planet Earth';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Run Code Online (Sandbox Code Playgroud)
这应该被视为一个错误吗?PHP根本不会返回任何语法错误.
我已将我的配置设置为使用本地beanstalkd服务器:
'beanstalkd' => array(
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
)
Run Code Online (Sandbox Code Playgroud)
如何将作业推送到另一个beanstalkd服务器?
Queue::push(function($job)
{
// This pushes to local beanstalkd
});
Queue::pushToRemoteBeanstalkdInstance(function($job)
{
// ?
});
Run Code Online (Sandbox Code Playgroud) Log::info('Sending email', array(
'title' => $attributes['title'],
'recipient' => $attributes['email']
));
Mail::queue('emails.welcome', $attributes, function($message) use ($attributes)
{
$message
->to($attributes['email'])
->subject($attributes['title']);
});
Run Code Online (Sandbox Code Playgroud)
传递给闭包的问题是什么Mail::queue
.怎么了?这与文档中的内容完全相同.
所以我使用以下配方:
include_recipe "build-essential"
node_packages = value_for_platform(
[ "debian", "ubuntu" ] => { "default" => [ "libssl-dev" ] },
[ "amazon", "centos", "fedora", "centos" ] => { "default" => [ "openssl-devel" ] },
"default" => [ "libssl-dev" ]
)
node_packages.each do |node_package|
package node_package do
action :install
end
end
bash "install-node" do
cwd Chef::Config[:file_cache_path]
code <<-EOH
tar -xzf node-v#{node["nodejs"]["version"]}.tar.gz
(cd node-v#{node["nodejs"]["version"]} && ./configure --prefix=#{node["nodejs"]["dir"]} && make && make install)
EOH
action :nothing
not_if "#{node["nodejs"]["dir"]}/bin/node --version 2>&1 | grep #{node["nodejs"]["version"]}"
end
remote_file …
Run Code Online (Sandbox Code Playgroud) php ×3
laravel ×2
laravel-4 ×2
beanstalkd ×1
chef-infra ×1
chef-recipe ×1
dom ×1
forms ×1
indexing ×1
javascript ×1
jquery ×1
mysql ×1
namespaces ×1
nginx ×1
object ×1
oop ×1
python ×1
python-3.x ×1
redirect ×1
rewrite ×1
ruby ×1
sql ×1
vagrant ×1
windows ×1
xpath ×1