开发者

Problem reading data from file special characters

My previous question and this question both are related a bit. please have a look at my previous question I did not found any other way to unserialize the data so coming with the string operation

I am able to get the whole content from file but not able to get the specific string from this content.

I want to search a specific string from these content but function stop working when the reach at first special character in the string. If I am searching something found before the special character the works properly.

String operation function of PHP not working prope开发者_高级运维rly when the encounter first special character in the string and stop processing immediately, Hence they does not give me the correct output.

Originally they looks like (^@)

:"Mage_Core_Model_Message_Collection":2:{s:12:"^@*^@_messages";a:0:{}s:20:"^@*^@_lastAddedMessage";N;}

but when I did echo they are display as ?

Here is the code what I tried

$file='/var/www/html/products/var/session/sess_ciktos8icvk11grtpkj3u610o3';
$contents=file_get_contents($file);
$contents=htmlspecialchars($contents);
//$contents=htmlentities($contents);
echo $contents;

$restData=strstr($contents,'"id";s:4:"');
echo $restData;
$id=substr($restData,0,strpos($restData,'"'));
echo $id;

I changed the default_charset to iso-8859-1 and also utf-8 but not working with both

Please let me know How I can resolve this. Thanks.


These characters that you see as ^@ are actually null bytes. They don't have any proper display, neither they are meant to be displayed - it's an internal representation of protected properties in the engine. You're not supposed to mess with them.

As for resolving, it'd be nice to know what kind of resolution you seek - what result are you trying to achieve?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜