nieuwe-printr-functie-met-objecten-ondersteuning

Gesponsorde koppelingen

PHP script bestanden

  1. nieuwe-printr-functie-met-objecten-ondersteuning

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function print_r(variable,lvl,history) {
    var space = '  ';
    var linef = '<br/>';
    var output = '';
    if(typeof(history) == 'undefined') {
        var history = 'this';
    }
    if(typeof(lvl) == 'undefined') {
        var lvl = 0;
    }
    if(lvl==0) {
        output = '<span style="color:#00f;">' + history + '</span> = ';
    }
    var ws = '';
    for(var x = 0;x < lvl;x++) {
        ws += space;
    }
    
    if(variable == null) {
        return output+'<em title="null '+history+' = null;" style="color:#408;">null</em>'+((lvl==0)?';':'');
    } else if(typeof(variable) == 'object') {
        if(variable instanceof Array) {
            output += '['+linef;
            for(var x = 0;x<variable.length;x++) {
                output += ws+space+'<span style="color:#000;">'+x+'</span>:'+print_r(variable[x],lvl+1,history+'['+x+']')+','+linef;
            }
            return output + ws + ']'+((lvl==0)?';':'');
        } else {
            output += '{'+linef;
            for(var key in variable) {
                output += ws+space+'<span style="color:#00f;">'+key+'</span>:'+print_r(variable[key],lvl+1,history+'.'+key)+','+linef;
            }
            return output+ws+'}'+((lvl==0)?';':'');
        }
    } else if(typeof(variable) == 'string') {
        return output+'<span title="string '+history+' = &quot;'+variable.toString()+'&quot;;" style="color:#F00;">"'+variable.toString()+'"</span>'+((lvl==0)?';':'');
    } else if(typeof(variable) == 'function') {
        return output+'<span title="function '+history+'();" style="color:#070">'+variable.toString().replace(/\{((\n|\r|.)*)\}/gi,'{}').replace(/^function \(/gi,'function(')+'</span>'+((lvl==0)?';':'');
    } else if(typeof(variable) == 'number') {
        return output+'<span title="number '+history+' = '+variable.toString()+';" style="color:#000">'+variable.toString()+'</span>'+((lvl==0)?';':'');
    } else if(typeof(variable) == 'undefined') {
        return output+'<em title="undefined '+history+' = undefined;" style="color:#f66;">undefined</em>'+((lvl==0)?';':'');
    } else if(typeof(variable) == 'boolean') {
        return output+'<em title="boolean '+history+' = '+(variable?'true':'false')+';" style="color:#070;">'+(variable?'true':'false')+'</em>'+((lvl==0)?';':'');
    } else {
        return output+'<span title="'+typeof(variable)+' '+history+' = new '+typeof(variable)+';" style="color:#888;">('+typeof(variable)+')</span>'+((lvl==0)?';':'');
    }
}


Heb syntax highlighting niet aan kunnen zetten met < ? en ? >: de class.bbcode.php gaf errors!

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.