我正在使用PHPExcel 1.7.8读取.xls由radom用户上传的文件.所有都正常使用有效.xls文件,但现在我想用无效文件进行一些测试,以检查程序是否显示良好的错误消息.
所以我拿了一个.csv文件,并将其重命名为.xls(没有转换任何东西,只是更改名称)到最后,只是为了检查......
破碎!:)
DOM ELEMENT: HTML
DOM ELEMENT: BODY
DOM ELEMENT: P
START OF PARAGRAPH:
END OF PARAGRAPH:
FLUSH CELL: A1 => block,date,hour...
array
1 =>
array
'A' => string 'block,date,hour...' (length=2777)
{"step":"error","errors":[],"warnings":[]}
Run Code Online (Sandbox Code Playgroud)
就像你可以看到的那样,显示一条错误消息,我没有要求,然后是我经常写的JSON.
它出现在这一行:
<?php
echo "Loading file\n";
try {
if (!($objPHPExcel = PHPExcel_IOFactory::load('path'))) {
echo "Failed\n";
return;
// ...
}
} catch(Exception $e) {
echo 'Exception !';
}
echo "Done\n";
Run Code Online (Sandbox Code Playgroud)
这段代码显示:
Loading file
/!\ ERROR MESSAGE ABOVE …Run Code Online (Sandbox Code Playgroud) 我想知道用户是否是 root,而不关心该用户是否使用类似 fakeroot 的工具。
我尝试了这些功能getuid(),geteuid()并且getlogin(),但是当我启动fakeroot命令时,每个功能都发送我自己的帐户信息,而不是root.
对于这段代码:
printf("%d %d %s\n", getuid(), geteuid(), getlogin());
Run Code Online (Sandbox Code Playgroud)
这是我得到的:
% fakeroot ./busybox rm
1000 1000 julien
Run Code Online (Sandbox Code Playgroud)
当我想要得到类似的东西时:
0 0 root
Run Code Online (Sandbox Code Playgroud)
(登录就足够了)
我有一个类模板,简化,有点像:
template<typename T>
class A
{
protected:
T _data;
public:
A* operator%(const A &a2) const
{
A * ptr;
ptr = new A(this->_data % a2._data);
return ptr;
}
};
Run Code Online (Sandbox Code Playgroud)
另一个继承自这个类的类:
class B : public A<double>
{
// ...
};
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,编译器说:
invalid operands of types ‘double’ and ‘const double’ to binary ‘operator%’
Run Code Online (Sandbox Code Playgroud)
然后,我试图将我operator%的专用于double和float,因为%似乎不可能用于那些类型.我在A类声明后添加了以下代码.
template<>
A* A<double>::operator%(const A &a2) const
{
A * ptr;
ptr = new A((uint32_t)this->_data % (uint32_t)a2._data);
return ptr;
}
Run Code Online (Sandbox Code Playgroud)
我得到这个错误,我实际上不明白为什么...... …
我有一个以 UTF16 编码的 xml 文件,我想将其转换为 UTF8 以进行处理。如果我使用这个命令:
iconv -f UTF-16 -t UTF-8 file.xml > converted_file.xml
Run Code Online (Sandbox Code Playgroud)
该文件已正确转换,我能够处理它。我想在 nodejs 中做同样的事情。
目前我有我的文件缓冲区,我已经尝试了所有我能想到的以及我可以在互联网上找到的东西,但没有成功。
以下是我迄今为止尝试过的一些示例:
content = new Buffer((new Buffer(content, 'ucs2')).toString('utf8'));
Run Code Online (Sandbox Code Playgroud)
我也试过使用这些功能:
http://jonisalonen.com/2012/from-utf-16-to-utf-8-in-javascript/ /sf/answers/1022126591/
第一个不会改变任何东西,链接只给我中文字符。
我正在尝试使用IndexedDB,一切都运行良好,直到几个小时前我的.open()回调停止在Chrome上调用(在Safari上测试,它工作正常).
RT.prototype.setupIndexedDB = function (callback) {
var dbName = "test";
var dbVersion = 1;
var indexedDB = window.indexedDB ||
window.webkitIndexedDB ||
window.mozIndexedDB;
console.log("setup indexed db");
var request = indexedDB.open(dbName, dbVersion);
request.onsuccess = function(e) {
console.log("db request success");
};
request.onblocked = function(e) {
console.log("DB open blocked", e);
};
request.onerror = function(err) {
console.log("error", err);
};
request.onversionchange = function(err) {
console.log("onversionchange", err);
};
request.onupgradeneeded = function(e) {
console.log("upgrade needed");
};
};
Run Code Online (Sandbox Code Playgroud)
我查看了Chrome开发人员工具IndexedDB,没有任何东西......
任何人都知道发生了什么?
谢谢
编辑:完全重启浏览器就行了,但我仍然对发生了什么感兴趣.
如果字符串在数组中或数组为空,我想发出一个请求,该请求从我的集合中返回元素。我尝试了以下方法:
Collection.all_of(or: [{ assets: my_asset }, { assets: [] } ])
Run Code Online (Sandbox Code Playgroud)
但这不起作用。
这有效但不适用于空数组:
Collection.where(assets: my_asset)
Run Code Online (Sandbox Code Playgroud) 我有以下代码(使用text/template):
inventory := map[string]string{"name of the movie": "hello"}
tmpl, err := template.New("test").Parse("Movie name ") // I want to display "hello" there
if err != nil { panic(err) }
err = tmpl.Execute(os.Stdout, inventory)
if err != nil { panic(err) }
Run Code Online (Sandbox Code Playgroud)
如您所见,我的地图键中有空格name of the movie.如何在parse参数中显示hello(哪个是值name of the movie)?
我想自定义这样的滑块:
所以我想知道是否有一种简单的CSS方法,它将适应父元素的宽度.或者如果我需要在我的html中添加圆圈并设置给定百分比的颜色.
这是我的两个问题,我不知道如何在完整的CSS中做:
background: @color有可能吗?
谢谢!
我不想用javascript来使用任何东西,我的网页很重,因为:p