[help] cara penggunaan isset

Discussion in 'Programming' started by cah pekalongan, Sep 23, 2015.

  1. cah pekalongan

    cah pekalongan Member

    Joined:
    Aug 22, 2015
    Messages:
    28
    Likes Received:
    5
    Trophy Points:
    8
    met sore agan2 yg ganteng.. *bohong*
    ada yg bisa bantuin ane benerin kode yang ada dibawah ?
    bingung ane gan *mati*
    soalnya kadang $data2 = $code->link->anu[2]->attributes(); ga ada, kadang ada.. kayak tuyul gitu lah pokokmen.. jadi ane gunain isset, tapi bingung.

    Fatal error: Call to a member function attributes() on a non-object

    Code:
      
      foreach ($xml->channel->item as $item) {
      $code = $item->children('code',true);
      if(isset($data)
      {
      $data = $code->link->anu[1]->attributes();
      }
      else
      {
      $data2 = $code->link->anu[2]->attributes();
      }
    
    
    XML Kadang begini gan

    Code:
    <code:link>
    <code:anu url='http://googgel.com'/>
    <code:anu url='http://googgel.com/anbs'/> /// (target 2) kalo target satu ga ada ini yg mau ane ambil
    <code:anu url='http://googgel.com/sdkhdk'/> /// (target 1) ini yang mau ane ambil gan
    </code:link>
    
    Kadang gini aja

    Code:
    <code:link>
    <code:anu url='http://googgel.com'/>
    <code:anu url='http://googgel.com/anbs'/> /// (target 2) kalo target satu ga ada ini yg mau ane ambil
    </code:link>
    
     
    Last edited: Sep 23, 2015
    lasealwin likes this.
  2. ziuma

    ziuma Well-Known Member

    Joined:
    May 23, 2014
    Messages:
    1,564
    Likes Received:
    240
    Trophy Points:
    63
    sabar, ngak usah disundul-sundul
    mungkin yang lain lagi sibuk

    coba saya ngerti sama pertanyaannya dan bisa bantu (pasti saya akan bantu)
    sayangnya saya ngak ngerti pertanyaannya (kalaupun ngerti kadang jawabnya ngak bisa :D)
    colek dulu @Fahmi @ncang
     
    cah pekalongan and lasealwin like this.
  3. KangAndre

    KangAndre Member

    Joined:
    Jan 25, 2014
    Messages:
    10,253
    Likes Received:
    2,716
    Trophy Points:
    413
    cah pekalongan and lasealwin like this.
  4. lasealwin

    lasealwin Well-Known Member

    Joined:
    Aug 1, 2015
    Messages:
    1,862
    Likes Received:
    171
    Trophy Points:
    63
    Wah...
    PHP dan bahasa pemograman, saya tidak ngerti sama sekali.
    Tapi kalau php-in cewek saya udah pernah....
    :D :D :D
     
    localhost and cah pekalongan like this.
  5. cah pekalongan

    cah pekalongan Member

    Joined:
    Aug 22, 2015
    Messages:
    28
    Likes Received:
    5
    Trophy Points:
    8
    hehe sorry ya gan,soal e kebelet *belajar*

    tq om, tapi masih bingung.. *kaget1*

    apalagi ane gan, dah berkali2 ane phpin cewe.. *bohong*
     
  6. KangAndre

    KangAndre Member

    Joined:
    Jan 25, 2014
    Messages:
    10,253
    Likes Received:
    2,716
    Trophy Points:
    413
    Saya juga bingung, php tsb digunakan dimana dan untuk apa?
     
    cah pekalongan likes this.
  7. cah pekalongan

    cah pekalongan Member

    Joined:
    Aug 22, 2015
    Messages:
    28
    Likes Received:
    5
    Trophy Points:
    8
    itu buat ngambil sesuatu dari file xml. *belajar*
     
  8. Samsul Arifin

    Samsul Arifin Member

    Joined:
    Feb 9, 2015
    Messages:
    54
    Likes Received:
    1
    Trophy Points:
    8
    Halo sabtu ceria,

    Itu karena fungsi attributes() gak ada value nya gan.

    cobain gini:

    foreach ($xml->channel->item as $item) {
    $code = $item->children('code',true);

    if(isset($data)
    $i = 0;
    foreach($code->children() as $item) {
    echo $item[$i]->url;
    echo "<br>";
    $i++;
    }
    }
     
    Last edited: Oct 24, 2015
Loading...

Share This Page