GeRik Posted June 27, 2010 Report Share Posted June 27, 2010 Hmm kāds var palīdzet kā noteikt pārbaudi vai ir faila vai nav ? piemēram $check = simplexml_load_file("http://www.something.com/feeds/something/1275127"); if($check == $kkas){ echo "Pareizi"; }else{ echo "Nepareizi"; } Kā īsti ir pareizi tā parbaude jāveic vienkārši man vai ir vai nav pareizi vienalga rāda Pareizi. Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted June 28, 2010 Report Share Posted June 28, 2010 reizi tā parbaude jāveic vienkārši man vai ir vai nav pareizi vienalga rāda Pareizi. ------- no manualja -- Return Values Returns an object of class SimpleXMLElement with properties containing the data held within the XML document. On errors, it will return FALSE. --------- Attieciigi parbaudi vai tika izveidots objekts, nevis vai ir vienads ar mainiigo (var parbaudiit arii vai nav false ) -- Bet skjiet ka parezak tomer buutu parbaudiit vai dotais fails eksistee sakuma, nevis megjinat apstradat un tad konstatet ka naff .. -- lai parbaudiitu vai fails ir vai nav var izmantot file_exists() f-ju. -- P.S. IZMANTO TACHU MANUALI, tur viss ir paraadiits Quote Link to comment Share on other sites More sharing options...
GeRik Posted June 28, 2010 Author Report Share Posted June 28, 2010 Hmm Tu Nesaprati function something_exists($var) { $check = simplexml_load_file("http://www.something.com/feeds/something/".$var); if($check == true) { return true; } else { return false; die; } } if(isset($_GET['id'])){ $parbaude = something_exists($_GET['id']); if($parbaude == true){ echo "Kautkas Eksiste"; }else{ echo "Kautkas Neeiksiste"; } } echo ' <form action="" method="get"> <input type="text" name="id" /> <input type="submit" value="Check" /> </form>'; Ja Fails eiksiste man rada kautkas Neeksistē un ja neeksiste tad rāda arī ka neeksistē un erroru ka fails neiksistē ERRORS: Warning: simplexml_load_file(http://www.something.com/feeds/something/asdasd) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in ... on line 3 Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://www.something.com/feeds/something/asdasd" in ... on line 3 Quote Link to comment Share on other sites More sharing options...
briedis Posted June 28, 2010 Report Share Posted June 28, 2010 (edited) Nevis, "nē, tu nesaprati", bet "nē, es sūdīgi izstāstīju". Tad tā arī saki, ka tev vajag nolasīt datus no adrese... Var darīt šādi: if($data = file_get_contents($url)){ $xml = simplexml_load_string($data); //... } Var, un pat ieteicams, datus iegūt izmantojot cURL... Edited June 28, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
GeRik Posted June 28, 2010 Author Report Share Posted June 28, 2010 Paldies :) var vērt ciet viss sanāca :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.