views:

30

answers:

1

I'm forced to use an older version of php on a server, and it seems to have a bug in the function file_get_contents(); I believe it's a bug because the issue doesn't happen on the current version of php.

$string = 'intraneturl/?really_long_example_query_parameters';

When I pass the $string into file_get_contents($string); the part with the query parameters seems to get truncated at some point because the returned information is different than when I run the exact same code on the up-to-date version of php on my dev machine.

My question is: How can I see the exact string that file_get_contents(); processed. I know what I sent in, but I don't believe it's processing it as I sent it. There may be a generic answer for viewing the innards of all functions via debugger or something. Do I need to use a debugger or is there a way to just print the information on the screen?

+1  A: 

Install something like Wireshark and take a look at the actual http request sent over the network.


Install XDebug and e.g. netbeans as frontend to step through the php script code and inspect variables, function calls, ...


Compile the php version with the --debug option and use a native C debugger to step through the php engine's code. For the win32 builds on windows.php.net there are debug packs that contain debug symbols for the release build (those are less "accurate" than a "real" debug build due to optimization).

VolkerK
Re: wireshark: This would have to be installed on the remote php server right? Not a problem to do this on my local machine, but there may be an issue installing on the remote php server. Thanks for the suggestion either way, looks like an interesting tool.
JMC
other options added. It shouldn't matter much where you install wireshark. You can inspect outgoing packets as well as incoming. You could even install wireshark on a completely different machine if it is within the same network segment with a network adapter in promiscuous mode, see http://en.wikipedia.org/wiki/Promiscuous_mode
VolkerK