0

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 properly 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.

Community
  • 1
  • 1
Shakti Singh
  • 84,385
  • 21
  • 134
  • 153

1 Answers1

2

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?

StasM
  • 10,593
  • 6
  • 56
  • 103