Jump to content
php.lv forumi

Pārbaude


GeRik

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by briedis
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...