小编Ele*_*rix的帖子

strtotime()的结果是否根据时区而改变?

strtotime($datetime)在PHP中使用将文本日期时间描述转换为Unix时间戳(请参阅下面的代码).

$datetime = '2012-04-17 00:00:00';
$timestamp = strtotime($datetime);
Run Code Online (Sandbox Code Playgroud)

然而,$timestamp时区(伦敦)的结果是1334617200,而时区(北京)则是1334620800.

谁能解释我为什么会这样?结果是strtotime()根据时区改变的吗?

提前致谢!

php

5
推荐指数
1
解决办法
8802
查看次数

Lua - 为什么允许函数调用后的字符串?

我正在尝试实现一个简单的C++函数,它检查Lua脚本的语法.为此,我使用Lua的编译器函数luaL_loadbufferx()并在之后检查其返回值.

最近,我遇到了一个问题,因为我认为应该被标记为无效的代码未被检测到,而是稍后脚本在运行时(例如,在lua_pcall())中失败.

示例Lua代码(可在官方Lua演示中测试):

function myfunc()
   return "everyone"
end

-- Examples of unexpected behaviour:
-- The following lines pass the compile time check without errors.
print("Hello " .. myfunc() "!") -- Runtime error: attempt to call a string value
print("Hello " .. myfunc() {1,2,3}) -- Runtime error: attempt to call a string value

-- Other examples:
-- The following lines contain examples of invalid syntax, which IS detected by compiler.
print("Hello " myfunc() …
Run Code Online (Sandbox Code Playgroud)

lua luac

5
推荐指数
1
解决办法
341
查看次数

标签 统计

lua ×1

luac ×1

php ×1