I'm having an issue with PHP losing data in a variable. There is quite a bit of data in the variable, because it basically contains a binary file, but I'm wondering if this is cause for it to completely lose it's information.
Looking at a snippet from my code which is used to deal with email attachments:
var_dump($data);
if (array_key_exists('filename', $params) || array_key_exists('name', $params)) {
var_dump($data);
...
}
The first var_dump gives the desired output of the file:
"string(283155) "
--Apple-Mail-5-930065543 ... etc
while the second gives an output of:
string(0) ""
...
string(0) ""
Any idea why this is happening? Does PHP just drop data in variables if they are really large? (I didn't think so, as I've never had this problem before)
If so, any workaround?
Thanks!
Edit: also worth mentioning that there is no code missing between these statements. I also just tried it with a shorter string and I'm getting the correct output for both var_dump calls
It should never happen. $data gets purified somewhere between var_dumps. It's hard to say where $data gets changed without seeing the code, but I had similar problems when I worked with old code that overused include. For example,
$data = "my_data";
include "file1.php" // $data can be changed here !
print($data); // not "my_data" anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With