v2.5.2
Giriş yap

Veri olmayan php api'yi çalıştırmama

erdal42
414 defa görüntülendi ve 1 kişi tarafından değerlendirildi
<div class="kutucugumuz"></div>

<?php

if ( isset($_GET['language']) ) {
  $language = $_GET['language'];
} else {
  $language = 'en';
}

if ( isset($_GET['userAgent']) ) {
  $userAgent = $_GET['userAgent'];
} else {
  $userAgent = 'WikiBot/1.0 (+http://'.$_SERVER['SERVER_NAME'].'/)';
}

if ( isset($_GET['betterResults']) and
     ($_GET['betterResults'] == 'false' or $_GET['betterResults'] == 0) ) {
  $betterResults = false;
} else {
  $betterResults = true;
}

if ( isset($_GET['proxy']) ) {
  $proxy = $_GET['proxy'];
} else {
  $proxy = null;
}

if ( isset($_GET['imageProxy']) and
     ($_GET['imageProxy'] == 'false' or $_GET['imageProxy']== 0) ) {
  $imageProxy = false;
} else {
  $imageProxy = true;
}

if ( isset($_GET['DEBUG']) ) {
  $DEBUG = $_GET['DEBUG'];
} else {
  $DEBUG = null;
}

// Set the Parameter
$options = array(
  'language'      => $language,
  'userAgent'     => $userAgent,
  'betterResults' => $betterResults,
  'proxy'         => $proxy,
  'imageProxy'    => $imageProxy,
  'DEBUG'         => $DEBUG,
);


require_once __DIR__.'/ciktisi.php';

// Start the Wikipedia API Class
$wiki = new wiki($options);

// Output the API Response
echo $wiki->api($_GET['q']);

// Print the Script Runtime in DEBUG Mode
if ( isset($DEBUG) ) {
  echo "<pre>\n\n\tRuntime: ".number_format((microtime(true)-$_SERVER['REQUEST_TIME_FLOAT']),3);
   }

?>

Merhabalar, yukarıdaki kodda aramalarda mesela üste verdiğim div'i apilerde sonuç çıkmayınca sadece içi boş kutucuk çıkıyor. Eğer sonuç yok ise nasıl tamamen div'i kaldırabiliriz ?

erdal42
563 gün önce

Hocam çalıştı :)

Sonuçlar çıkmadığında else'ye

<style>
.kutucugumuz {
    display:none;
}
</style>

diyerek gözükmemesini sağlatıyoruz.

Eğer sonuç var ise sıkıntısız bir şekilde yazdırıyor :)
Size nasıl teşekkür etsem az. Bu gibi sorunlarla karşılaştığımızda yardımımıza koştunuz. Artık php üzerine daha fazla düşeceğim. :)