• 23-06-2013, 21:50:45
    #1
    Şöyle bir kodum var , kod bir siteye bağlanıp veri çekiyor ama haliyle site kapalıysa yani çekemediyse hata veriyor.Hata veriyor ama hata vermesiyle beraber sayfanın devamını da açmayı bırakıyor.Yani bu kod sayfanın ortasında ve eğer hata çıkarsa sayfanın devamı açılmıyor.Hata çıkarsa bile hatayı yazdırmadan devam etmesinin bir yolu var mıdır ?

    $_REQUEST["host"] = $vt['host'];
    	$_REQUEST["port"] = $vt['port'];
    	$_REQUEST["locale"] = 22;
    	$_REQUEST["version"] = $vt['version'];
    	$_REQUEST["timeout"] = 45;
    
    	// Execute the server stats page and store the results. This code doesn't change.
    	ob_start();
    	include( "ServerStats.php" );
    	$result = ob_get_contents();
    	ob_end_clean();
    
    	// Breakup the output, this code doesn't change.
    	$result = str_replace( PHP_EOL, "", $result );
    	$parts = explode( "<br />", $result );
    
    	// Check the result
    	if( count( $parts[0] ) == 0 || $parts[0] != "Success" )
    	{
    		// TODO: When there is an error, you must output your error page,
    		// or handle the error based on the data in 'parts'. Read the 
    		// ServerStats.php file for various error messages to handle as well
    		// as play with incorrect command lines (like older version, short 
    		// timeout, etc... to test)
    		print_r( $parts );
    		die( "" );
    	}
    	// For this simple example, we output the data into a table.
    		for( $x = 0; $x < count( $parts ); ++$x )
    	{
    		$lines = explode( "|", $parts[$x] );
    		if( count( $lines ) < 5 ) // empty line or success message
    		{
    			continue;
    		}
    		echo "<tr>";
    		for( $y = 0; $y < count( $lines ); ++$y )
    		{
    			$line = $lines[$y];
    			// TODO: translate names, change the text of headers, or skip the entire line, if needed based on value.
    		echo   $line;
    		}
    		
    	}
  • 24-06-2013, 01:28:43
    #2
    Hataları yazdırmama & gizleme işlemini : error_reporting(0); ile çözebilirsiniz. Fakat bu işlem hata'dan sonra devam eder mi bilgim yok. Fakat bir kod hatalı ise php'nin onu görmezden gelip devam edeceğini zannetmiyorum var ise eğer bende öğrenmekten hiç çekinmem açıkcası.
  • 24-06-2013, 01:49:52
    #3
    Kod hatalı değil , site kapalıysa görmezden gelmesi lazım , onuda hallettim.