濮阳杆衣贸易有限公司

主頁 > 知識庫 > 使用lua實(shí)現(xiàn)php的print_r()函數(shù)功能

使用lua實(shí)現(xiàn)php的print_r()函數(shù)功能

熱門標(biāo)簽:新岸線智能電銷機(jī)器人 百度地圖標(biāo)注早餐區(qū)域 武漢外呼防封系統(tǒng)多少錢 清朝地圖標(biāo)注哈爾濱 漳州智云呼電話機(jī)器人 個人怎么在地圖標(biāo)注需要的店鋪 怎么去除地圖標(biāo)注 冀州市地圖標(biāo)注 地圖標(biāo)注大廈

之前寫了一些類似php的函數(shù),下面再來一個print_r()函數(shù),代碼如下:

復(fù)制代碼 代碼如下:

function pr (t, name, indent)  
    local tableList = {}  
    function table_r (t, name, indent, full)  
        local id = not full and name or type(name)~="number" and tostring(name) or '['..name..']'  
        local tag = indent .. id .. ' = '  
        local out = {}  -- result  
        if type(t) == "table" then  
            if tableList[t] ~= nil then  
                table.insert(out, tag .. '{} -- ' .. tableList[t] .. ' (self reference)')  
            else 
                tableList[t]= full and (full .. '.' .. id) or id 
                if next(t) then -- Table not empty  
                    table.insert(out, tag .. '{')  
                    for key,value in pairs(t) do  
                        table.insert(out,table_r(value,key,indent .. '|  ',tableList[t]))  
                    end  
                    table.insert(out,indent .. '}')  
                else table.insert(out,tag .. '{}') end  
            end  
        else 
            local val = type(t)~="number" and type(t)~="boolean" and '"'..tostring(t)..'"' or tostring(t)  
            table.insert(out, tag .. val)  
        end  
        return table.concat(out, '\n')  
    end  
    return table_r(t,name or 'Value',indent or '')  
end  
function print_r (t, name)  
    print(pr(t,name))  
end  
 
local a = {x=1, y=2, label={text='hans', color='blue'}, list={'a','b','c'}}  
 
print_r(a) 

您可能感興趣的文章:
  • php中理解print EOT分界符和echo EOT的用法區(qū)別小結(jié)
  • PHP學(xué)習(xí)之輸出字符串(echo,print,printf,print_r和var_dump)
  • 用js寫了一個類似php的print_r輸出換行功能
  • php輸出echo、print、print_r、printf、sprintf、var_dump的區(qū)別比較
  • PHP echo,print,printf,sprintf函數(shù)之間的區(qū)別與用法詳解
  • 用nodejs實(shí)現(xiàn)PHP的print_r函數(shù)代碼
  • PHP中echo,print_r與var_dump區(qū)別分析
  • php中print(),print_r(),echo()的區(qū)別詳解

標(biāo)簽:儋州 金昌 天門 德宏 臺灣 濰坊 天門 宣城

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《使用lua實(shí)現(xiàn)php的print_r()函數(shù)功能》,本文關(guān)鍵詞  使用,lua,實(shí)現(xiàn),php,的,print,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《使用lua實(shí)現(xiàn)php的print_r()函數(shù)功能》相關(guān)的同類信息!
  • 本頁收集關(guān)于使用lua實(shí)現(xiàn)php的print_r()函數(shù)功能的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    石棉县| 襄垣县| 平顶山市| 宾川县| 新和县| 平乡县| 永寿县| 沽源县| 兴义市| 墨玉县| 巴林左旗| 虞城县| 玛沁县| 泰州市| 襄樊市| 昭通市| 凉城县| 大余县| 定安县| 旺苍县| 信宜市| 陈巴尔虎旗| 图木舒克市| 吴桥县| 齐河县| 阳谷县| 竹北市| 东乡族自治县| 当阳市| 灵山县| 张家口市| 桐庐县| 林州市| 宜兴市| 中西区| 博湖县| 响水县| 靖西县| 嵩明县| 和平县| 长汀县|