0

I am experienced with Java and have some experience with PHP (the server scripting language I will be using unless anybody tells me I shouldn't for some reason. I want to just send a string via POST to the server. Because there is not actually a webpage being created, I can't just echo the string if it is received. How should I test if the string was received by the server?

Edit: After further research, it seems like echo doesn't just print to a browser, it sends a string through the http connection to whatever is connected to the php page. I should then be able to echo a response and receive it through an input string on the Java end. Is this correct?

michaelAdam
  • 1,119
  • 14
  • 30

2 Answers2

1

I believe you should be properly sending back Responde codes in your php scripts.

Please check: How to send a status code in PHP and Android: How get the status-code of an HttpClient request.

Community
  • 1
  • 1
  • This would be ideal in a full application, but at this time the OP is just starting out, so getting a handle on proper debugging is a good first step. – Mike May 16 '14 at 02:55
1

You could use echo, as you mentioned, but the more common and reusable method of debugging PHP as you progress is the use of error_log(). You can view its output on the PHP server in the php.log file, commonly found at /tmp/php.log.

You can watch this file in real-time via the Unix command tail -f /tmp/php.log.

Further, you can output various forms of data by calling it with print_r() like error_log(print_r($data, TRUE));.

Mike
  • 1,968
  • 18
  • 35
  • Thank you, I was hoping there was some kind of log. That sounds like exactly what I need. – michaelAdam May 16 '14 at 01:45
  • It seems that I don't have php error log configured and I can't seem to find the configuration files. It should be somewhere in /etc, right? But I can't even find /etc. I don't have much linux experience, could you help me out? I'm using ubuntu. – michaelAdam May 16 '14 at 02:50
  • Hmmm. Well, check your php.ini to see where your error log is set up for. The ini should be in /etc. – Mike May 16 '14 at 03:00
  • That's the issue though, I can't find any system files at all. No /etc, no /tmp, no /var – michaelAdam May 16 '14 at 03:01
  • Oh nevermind, its been a while since I used Linux. Found it. – michaelAdam May 16 '14 at 03:02
  • Cheers. Best of luck and godspeed with PHP. If you're from the Java world, give HHVM a look. You'll feel right at home. – Mike May 16 '14 at 03:05