forked from laruence/php-lua
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlua.php
More file actions
34 lines (33 loc) · 1.12 KB
/
lua.php
File metadata and controls
34 lines (33 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
$br = (php_sapi_name() == "cli")? "":"<br>";
if(!extension_loaded('lua')) {
dl('lua.' . PHP_SHLIB_SUFFIX);
}
$lua = new \Lua();
echo "php.md5 = " . md5('abcd') . "\n";
echo "php.sha1 = " . sha1('abcd') . "\n";
echo "php.crc32 = " . crc32('abcd') . "\n";
echo "php.crc32? = " . hexdec(hash('crc32','abcd')) . "\n";
echo "php.crc32b = " . hexdec(hash('crc32b','abcd')) . "\n";
echo "php.crc32c = " . hexdec(hash('crc32c','abcd')) . "\n";
echo "php.adler32 = " . hexdec(hash('adler32','abcd')) . "\n";
$lua->eval(
"PLUGIN_NAME = 'test'\n" .
"function getPluginInfo()\n" .
" return {name = 'test'}\n" .
"end\n" .
"function testVar()\n" .
" print('PLUGIN_NAME = ' , PLUGIN_NAME,'\\n')\n" .
"end\n" .
"print ('Hello',',','World','!','\\n')\n" .
"print('hash.md5 = ' , hash.md5('abcd') , '\\n')\n".
"print('hash.sha1 = ' , hash.sha1('abcd') , '\\n')\n" .
"print('hash.crc32b = ' , hash.crc32b('abcd') , '\\n')\n".
"print('hash.adler32 = ' , hash.adler32('abcd') , '\\n')\n" .
""
);
var_dump($lua->call('getPluginInfo'));
var_dump($lua->PLUGIN_NAME);
$lua->PLUGIN_NAME = 'hello';
var_dump($lua->PLUGIN_NAME);
$lua->call('testVar');