Please consider the following code:
$imagePath = "https://s22.postimg.org/3k3o9ly8t/testigo.jpg";
$imagedata = get that image data through curl and store in this variable;
echo strlen($imagedata); // outputs 4699
if(strlen($imagedata) == 4699 ) {
echo "length is 4699";
}
The above if-condition never becomes true even though the strlen value is 4600. It seems very strange; am I missing anything? I've already tried mb_strlen
, but to no avail.
Update: It seems to work for certain images, but not for the following image.
Code:
$strImageURL = "https://s22.postimg.org/3k3o9ly8t/testigo.jpg";
$strImageData = getData($strImageURL);
echo "<br />" . strlen($strImageData);
if(strlen($strImageData) === 4699) {
echo "true";
}
function getData($strSubmitURL)
{
$strData = null;
$ch = curl_init();
//return parameter
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 140);
//site name
curl_setopt($ch, CURLOPT_URL,$strSubmitURL);
// don' verify ssl host
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
$strData = curl_exec ($ch);
if (!$strData) {
//die ("cURL error: " . curl_error ($ch) . "\n");
return '';
}
curl_close ($ch);
unset($ch);
return $strData;
}
4669` However.... your code has: `if(strlen($strImageData) == 4699) {` Four Six _NINE_ Nine... maybe, change the _NINE_ to a Six !! – Joeme Sep 10 '13 at 19:37