urlencode MAX zaman aşımı hata almaya devam

0 Cevap

Bu kod bir hata almaya devam:

<?php 
function encode_object(&$obj) {
  foreach ($obj as &$current) {
    if (is_string($current) or is_object($current) or is_array($current)) {
      if (is_object($current) or is_array($current)) {
        encode_object($current);
      }
      if (is_string($current)) {
        $current = urlencode($current);
      }
    }
  }
}
?>

Bu kod daha önce çalışmış ama nedense her zaman bir çalışma ben alıyorum:

Ölümcül hata: satır 9 * aşıldı 30 saniye Maksimum yürütme zamanı

Ne yapmaya çalışıyorum, o bir nesneyi vermek bunun üzerinden arama ve dizeleri tüm kodlamak mümkün değildir.

Ben birden çok kez denedim ama aynı hatayı almaya devam gelmiş

I am using: Apache 2.2.15.0 PHP 5.3.3 Windows 7 Ultimate build 7600

EDIT: The input I'm entering is an error that, after going through this function, is meant to be converted into JSON and read by javascript through ajax. The input in this case would be:

array("error"=>
  array(
    "error"=>"error",
    "number"=>2,
    "message=>"json_encode() [<a href='function.json-encode'>function.json-encode<\/a>]: recursion detected",
    "line"=>22))

That is another error that i will worry about later, but it seems that when I put $obj['error']['message'] = 'blah'; on the object before I send it, the code works fine. So there is something about

  json_encode() [<a href='function.json-encode'>function.json-encode<\/a>]: recursion detected

O urlencode bir sorun yaşıyor gibi görünüyor.

0 Cevap