Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to wirte laravel dd function in php

function d($data){
    if(is_null($data)){
        $str = "<i>NULL</i>";
    }elseif($data == ""){
        $str = "<i>Empty</i>";
    }elseif(is_array($data)){
        if(count($data) == 0){
            $str = "<i>Empty array.</i>";
        }else{
            $str = "<table style="border-bottom:0px solid #000;" cellpadding="0" cellspacing="0">";
            foreach ($data as $key => $value) {
                $str .= "<tr><td style="background-color:#008B8B; color:#FFF;border:1px solid #000;">" . $key . "</td><td style="border:1px solid #000;">" . d($value) . "</td></tr>";
            }
            $str .= "</table>";
        }
    }elseif(is_resource($data)){
        while($arr = mysql_fetch_array($data)){
            $data_array[] = $arr;
        }
        $str = d($data_array);
    }elseif(is_object($data)){
        $str = d(get_object_vars($data));
    }elseif(is_bool($data)){
        $str = "<i>" . ($data ? "True" : "False") . "</i>";
    }else{
        $str = $data;
        $str = preg_replace("/
/", "<br>
", $str);
    }
    return $str;
}

function dnl($data){
    echo d($data) . "<br>
";
}

function dd($data){
    echo dnl($data);
    exit;
}

function ddt($message = ""){
    echo "[" . date("Y/m/d H:i:s") . "]" . $message . "<br>
";
}
Comment

PREVIOUS NEXT
Code Example
Php :: strpos php 
Php :: php authentication 
Php :: php get user county 
Php :: acf looping through post types 
Php :: Doctor Strange 
Php :: Disabling Caching of Queries Laravel Model Cache 
Php :: laravel sharing image 
Php :: Call to undefined function GuzzleHttp\_idn_uri_convert() 
Php :: php json_encode float 
Php :: php replace string 
Php :: destruct php 
Php :: php, Africa timezones 
Php :: spaceship operator 
Php :: Laravel - Resize image size using Laravel image class 
Php :: laravel request input default value 
Php :: foreach sort orderby php 
Php :: Best Security tools for php 
Php :: rendering json in laravel 
Php :: symfony form submit on refresh 
Php :: php echo html and variable 
Php :: file get content php post 
Php :: replace last two characters string php 
Php :: error laravel 404 in server 
Php :: call jquery function in php code 
Php :: how to use php 
Php :: download file using jquery php 
Php :: is legged in wodpress 
Php :: wordpress rest_no_route custom post type 
Php :: get dates between two dates using specific interval using carbon 
Php :: spatie laravel pdf image 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =