本着学习Lua的态度, 写了一个PHP扩展Plua, 把Lua解析器嵌入了PHP.
Lua的堆栈式传参, 很值得借鉴, 这点上, 感觉比PHP用一个结构体表示弱类型, 要来的更严格, 更可靠一些.
目前可以想到的应用场景, 是可以实现一种编写(Lua), 多处调用(C, PHP, Java等).
不废话了, 项目主页: Plua
代码在Google code上:http://code.google.com/p/plua/
<?php
$lua = new Plua($lua_script_file = NULL);
$lua->eval("lua_statements"); //eval lua codes
$lua->include("lua_script_file"); //import a lua script
$lua->assign("name", $value); //assign a php variable to Lua
$lua->register("name", $function); //register a PHP function to Lua with "name"
$lua->call($string_lua_function_name, array() /*args*/);
$lua->call($resouce_lua_anonymous_function, array() /*args);
$lua->call(array("table", "method"), array(...., "push_self" => [true | false]) /*args*/);
$lua->{$lua_function}(array()/*args*/);
?>**后记: Plua项目现在已经取代了原来的Lua成为了PECL的Lua扩展, Plua也改名为了Lua, 所以请使用最新的Lua**