RHX adlı üyeden alıntı: mesajı görüntüle
Öncelikle ilgin için teşekkür ederim ama aşağıdaki kodu
<?php 
     
    header("Content-Type: text/plain; charset=UTF-8"); 
     
    $results = (object) array( 
        "status" => true, 
        "category" => (object) array( 
            "ID" => 1, 
            "title" => "title", 
            "description" => "description" 
        ), 
        "posts" => array( 
            (object) array( 
                "ID" => 1, 
                "type" => "post", 
                "title" => "title", 
                "content" => "content", 
                "excerpt" => "excerpt", 
                "published_at" => (time() - (72 * 60 * 60)), 
                "comments" => array() 
            ), 
            (object) array( 
                "ID" => 2, 
                "type" => "post", 
                "title" => "title", 
                "content" => "content", 
                "excerpt" => "excerpt", 
                "published_at" => (time() - (24 * 60 * 60)), 
                "comments" => array() 
            ) 
        ) 
    ); 
     
    print_r( 
        json_encode( 
            $results, 
            JSON_PRETTY_PRINT 
        ) 
    );
1.php eklediğimde ve tarayıcıdan 1.php çalıştırdığımda şu hatayı almaktayım

<br />
<b>Warning</b>: json_encode() expects parameter 2 to be long, string given in <b>/home/***/public_html/demo/maps/list.php</b> on line <b>38</b><br />
Arkadaşım JSON_PRETTY_PRINT olmadan kullan. Php sürümün eskidir, ondan hata veriyordur. 5.4.0 lazım o seçenek için.