所以例如我有这个代码:
class Object{
public $tedi;
public $bear;
...some other code ...
}
Run Code Online (Sandbox Code Playgroud)
现在您可以看到此类中有公共变量.我想做的是以动态方式制作这些变量,其功能如下:
private function create_object_vars(){
// The Array what contains the variables
$vars = array("tedi", "bear");
foreach($vars as $var){
// Push the variables to the Object as Public
public $this->$var;
}
}
Run Code Online (Sandbox Code Playgroud)
那么我应该如何以动态方式创建公共变量呢?
我正在尝试以这种方式重定向node.js中我的应用程序的url:
// response comes from the http server
response.statusCode = 302;
response.setHeader("Location", "/page");
response.end();
Run Code Online (Sandbox Code Playgroud)
但是当前的页面与新的页面混合在一起,看起来很奇怪:| 我的解决方案看起来完全合乎逻辑,我不知道为什么会发生这种情况,但如果我在重定向后重新加载页面就可以了.
无论如何,在节点中进行HTTP重定向的正确方法是什么?
是否可以忽略捕获并返回链?
promiseA() // <-- fails with 'missing' reason
.then(promiseB) // <-- these are not going to run
.then(promiseC)
.catch(function(error, ignore){
if(error.type == 'missing'){
ignore() // <-- ignore the catch and run promiseB and promiseC
}
})
Run Code Online (Sandbox Code Playgroud)
这样的事情可能吗?
我应该如何使用CSS:
我希望有两个divs或更多它们width应该在percent,但在这个例子中,div之间的边距应该是固定的30px

对我来说问题是两个div之间的余量,因为我可以把div放到一个更大的div中,并将左右填充设置为30px,这没关系,但是我应该怎么做两个div之间的边距?
如果我尝试添加例如第一个div,margin-right:30px;那么div 的宽度70% + 30px将是总体上大于100%而第二个div将下降.
那么这个解决方案是什么?
如果我重新加载我的应用程序(从带有重新加载按钮的浏览器)很多时候50 reload/10 seconds它会给我这个错误:
events.js:45
throw arguments[1]; // Unhandled 'error' event
^
Error: EBADF, Bad file descriptor
Run Code Online (Sandbox Code Playgroud)
这在我看来像带宽错误或类似的东西,最初我在使用HTML 5 Audio API时遇到错误,如果我按顺序加载音频文件10-15次,那么我就得到了错误,但是现在我发现我在没有音频API的情况下得到错误只是通过重新加载网站很多次,Safari也比Chrome更快地给我错误(WTF?)
我正在使用带有express+的Node.js 0.4.8,jade并且我还使用该db-mysql模块连接到MySQL数据库.
我在网上找不到任何关于这个主题的文章有什么帮助,所以pleeease让我知道什么可能导致这个错误,因为它真的令人困惑:(
如果我跑,我会收到此错误
curl http://npmjs.org/install.sh | sh
Run Code Online (Sandbox Code Playgroud)
即使是sudo.
cirk@cirk-Parallels-Virtual-Platform:~$ curl http://npmjs.org/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3902 100 3902 0 0 6138 0 --:--:-- --:--:-- --:--:-- 12546
fetching: http://registry.npmjs.org/npm/-/npm-1.0.18.tgz
0.4.9
1.0.18
Skipping 0.x cruft clean
! [ -d .git ] || git submodule update --init --recursive
node cli.js cache clean
node cli.js rm npm -g -f --loglevel error
node cli.js install -g -f
npm ERR! error …Run Code Online (Sandbox Code Playgroud) 是否可以在被调用的javascript文件上使用javascript获取查询参数,如下所示:
// in html
<script src="/file.js?query=string"></script>
// in file.js
console.log(this.location.query)
Run Code Online (Sandbox Code Playgroud)
这可能是某种方式,或者我必须使用服务器?
提供API的服务
我读/听说有很多服务可以让API做到这一点,但是我真的不想依赖任何人,所以如果有办法在没有他们的情况下让我知道.
服务器端
而且我读/听说这是在服务器端编码完成的,这使我感到困惑,我一直认为这是由Javascript完成的.
IP列表
我还读到/听说那些提供API的服务他们有来自ISP的非常庞大的IP列表,他们可以通过这个列表确定国家,这是真的吗?如果我想在没有API的情况下单独使用它,我是否也应该有一个列表?
我想::before在一些表格单元格上添加一个选择器position:absolute,但它失败了:
table{ border:1px solid #ccc; padding:10px; }
table td{ border:1px solid #ccc; padding:5px; }
.useBefore::before{
content:'before';
position:absolute;
}Run Code Online (Sandbox Code Playgroud)
<table>
<tbody>
<tr>
<td>bird</td>
<td>animal</td>
<td>nature</td>
</tr>
<tr class='useBefore'>
<td>building</td>
<td>robot</td>
<td>city</td>
</tr>
</tbody>
</table>Run Code Online (Sandbox Code Playgroud)
我注意到如果我将其添加::before到所有的那个tr,那么它的工作原理:
table{
border:1px solid #ccc;
padding:10px;
}
table td{
border:1px solid #ccc;
padding:5px;
}
tr::before{
content:'before';
position:absolute;
}Run Code Online (Sandbox Code Playgroud)
<table>
<tbody>
<tr>
<td>bird</td>
<td>animal</td>
<td>nature</td>
</tr>
<tr class='useBefore'>
<td>building</td>
<td>robot</td>
<td>city</td>
</tr>
</tbody>
</table>Run Code Online (Sandbox Code Playgroud)
但这不是我想要的,因为我只想在其中一些上添加它.