我完全被Lua的变量范围和函数参数传递(值或引用)搞糊涂了.
请参阅以下代码:
local a = 9 -- since it's define local, should not have func scope
local t = {4,6} -- since it's define local, should not have func scope
function moda(a)
a = 10 -- creates a global var?
end
function modt(t)
t[1] = 7 -- create a global var?
t[2] = 8
end
moda(a)
modt(t)
print(a) -- print 9 (function does not modify the parent variable)
print(t[1]..t[2]) -- print 78 (some how modt is modifying the …Run Code Online (Sandbox Code Playgroud) 为什么不在Luat:insert(9)工作?
(我想在表的末尾附加值9)
t = {1,2,3}
table.insert(t, 9) -- works (appends 9 to end of table t)
t:insert(9) -- does NOT work
Run Code Online (Sandbox Code Playgroud)
我一般都想
a.f(a,x)a:f(x)在Lua中是平等的
我有一个PHP应用程序.
我允许用户将文件上传到我的Web应用程序.
问题:$_FILES["filename"]["tmp_name"]在PHP中清理上传文档的文件名的最佳方法是什么?
更新:
我可以获取上传文件名的MD5并将其用作新分配的文件名吗?如果是这样,我如何在PHP中执行此操作?