Autor | Zpráva | ||
---|---|---|---|
unlucky Profil |
#1 · Zasláno: 22. 8. 2012, 00:18:55
<?php $a= '2.4'; $b=file_get_contents("x.txt"); ?> v x.txt je jenom 2.4 kdy jsou tyto 2 stringy stejne (tecka tam je) |
||
Sir Tom Profil |
unlucky:
„kdy jsou tyto 2 stringy stejne“ zkus si to: if($a == $b) nebo if($a === $b) |
||
unlucky Profil |
to jsem samozrejme zkousel, ale porad mi to hlasi, ze nejsou stejne.
ajaxem $d=file_get_contents("http://sdfdsfs.cz/cms_version.txt"); mysql_query("update settings set value='$d' where name='current_version'"); if($d===$_POST['version']){ echo "UPDATED web verze: $d - moje verze $_POST[version]"; }else{ echo "OLD web verze $d -moje verze $_POST[version]"; } echo mi zobraz 2.4 a 2.4 |
||
Jan Tvrdík Profil |
#4 · Zasláno: 22. 8. 2012, 10:46:43
unlucky:
Pravděpodobně bude v tom souboru x.txt na konci ještě odřádkování, takže potřebuješ ještě použít trim.
$a = '2.4'; $b = trim(file_get_contents('x.txt')); if ($a === $b) { ... } |
||
unlucky Profil |
v tom txt je jenom 2.4 trim a vsechno jsem zkousel
i compare_version vraci -1 |
||
panther Profil |
#6 · Zasláno: 22. 8. 2012, 10:55:59
unlucky:
co vraci var_dump($a); var_dump($b); |
||
unlucky Profil |
string(6) "2.4" string(3) "2.4"
plny kod <span onclick="javascript:ajaxfromtext('pages/check_version','version',2.4,'outa');">Check for newer version</span> var http_request = false; function makePOSTRequest(url, parameters,ajaxout) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { //http_request.overrideMimeType('text/xml'); http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } if (ajaxout!==null){ http_request.onreadystatechange = function() { alertContents(ajaxout); }; } http_request.open('POST', url, true); http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", parameters.length); http_request.setRequestHeader("Connection", "close"); http_request.send(parameters); } function alertContents(ajaxout) { if (http_request.readyState == 4) { if (http_request.status == 200) { //alert(http_request.responseText); result = http_request.responseText; document.getElementById(ajaxout).innerHTML = result; } else { alert('There was a problem with the request.'); } } } //add str from parameter function ajaxfromtext(script,varname,str,ajaxout) { var poststr = varname+"=" + encodeURI(str); makePOSTRequest(script+'.php', poststr,ajaxout); } |
||
Keeehi Profil |
unlucky:
„string(6) "2.4"“ - jsou tem nějaké znaky, které se nezobrazují <?php $a= '2.4'; $b=file_get_contents("x.txt"); echo "A: " for($i=0;$i<strlen($a);$i++) { echo ord($a[$i]).","; } echo "<br>\n"; echo "B: " for($i=0;$i<strlen($b);$i++) { echo ord($b[$i]).","; } echo "<br>\n"; |
||
panther Profil |
#9 · Zasláno: 22. 8. 2012, 11:22:13
unlucky:
ty tri znaky navic v souboru, neni to BOM? |
||
unlucky Profil |
ajo, je to bom
if(substr($string, 0,3) == pack("CCC",0xef,0xbb,0xbf)) { $string=substr($string, 3); } return $string; |
||
Časová prodleva: 12 let
|
0