## eval
##### Description
Evaluate a LUA script serverside
在服务器端执行LUA脚本
##### Parameters
*script* string.
*args* array, optional.
*num\_keys* int, optional.
##### Return value
Mixed. What is returned depends on what the LUA script itself returns, which could be a scalar value (int/string), or an array. Arrays that are returned can also contain other arrays, if that's how it was set up in your LUA script. If there is an error executing the LUA script, the getLastError() function can tell you the message that came back from Redis (e.g. compile error).
这个函数返回的结果是函数传输的LUA脚本的执行结果。结果可以是一个普通的数据类型,也可以使一个数组,数组内也可以嵌套数组。无论返回的结果是什么,都是取决于你的LUA脚本是如何执行的。如果你传输的LUA脚本存在错误,那么getLastError()能够返回出REDIS对于这个错误的具体消息。
##### Examples
```
<pre class="calibre16">$redis->eval("return 1"); // Returns an integer: 1
$redis->eval("return {1,2,3}"); // Returns Array(1,2,3)
$redis->del('mylist');
$redis->rpush('mylist','a');
$redis->rpush('mylist','b');
$redis->rpush('mylist','c');
// Nested response: Array(1,2,3,Array('a','b','c'));
$redis->eval("return {1,2,3,redis.call('lrange','mylist',0,-1)}}");
```
##
- php-redis中文帮助手册
- 系统及通用函数
- construct
- connect,open
- pconnect, popen
- close
- setOption
- getOption
- ping
- echo
- randomKey
- select
- move
- rename, renameKey
- renameNx
- setTimeout,expire,pexpire
- expireAt,pexpireAt
- keys,getKeys
- dbSize
- auth
- bgrewriteaof
- slaveof
- object
- save
- bgsave
- lastSave
- type
- flushDB
- flushAll
- sort
- info
- resetStat
- ttl, pttl
- persist
- config
- eval
- evalSha
- script
- getLastError
- _prefix
- _unserialize
- dump
- restore
- migrate
- time
- String数据类型函数
- get
- set
- setex, psetex
- setnx
- del, delete
- getSet
- multi, exec, discard
- watch, unwatch
- subscribe
- publish
- exists
- incr, incrBy
- incrByFloat
- decr, decrBy
- mGet, getMultiple
- append
- getRange
- setRange
- strlen
- getBit
- setBit
- bitop
- bitcount
- mset, msetnx
- List数据类型相关函数
- lPush
- rPush
- lPushx
- rPushx
- lPop
- rPop
- blPop, brPop
- lSize
- lIndex, lGet
- lSet
- IRange,IGetRange
- lTrim,listTrim
- lRem,lRemove
- lInsert
- rpoplpush
- brpoplpush
- Set数据类型相关函数
- sAdd
- sRem, sRemove
- sMove
- sIsMember, sContains
- sCard, sSize
- sPop
- sRandMember
- sInter
- sInterStore
- sUnion
- sUnionStore
- sDiff
- sDiffStore
- sMembers, sGetMembers
- zSet数据类型相关函数
- zAdd
- zRange
- zDelete,zRem
- zRevRange
- zRangeByScore, zRevRangeByScore
- zCount
- zRemRangeByScore,zDeleteRangeByScore
- zRemByRank,zDeleteRangeByRank
- zSize,zCard
- zScore
- zRank,zRevRank
- zIncrBy
- zUnion
- zInter
- Hash数据类型相关函数
- hSet
- hSetNx
- hGet
- hLen
- hDel
- hKeys
- hVals
- hGetAll
- hExists
- hIncrBy
- hIncrByFloat
- hMset
- hMGet