Error404 Error404 - 7 months ago 21
PHP Question

Where can I see what print_r display on PHP?

I have a

REST API
with
Android
and
Slim framework
. I'm using
XAMPP
to connect it with a MySQL database, .

I don't know where
print_r
is displayed.

The
api.php
file is in
C:\Program Files\xampp\htdocs\project\app\api\api.php
.

I get the following message when I try to access
localhost/project/app/api/api.php
:


Access denied.


It's a message that I put with
define
function. In index.php:

define("CONSTANT",true);


In connect.php and api.php:

if(!defined("CONSTANT")) die("Access denied");

Answer

Finally, testing different options during some hours, I get the solution.

If you are changing three values in your PUT method of your REST API, for example, name, description and idCar, after setting their new values (that you send from your Android application) you can put on your PHP script:

print_r([$name,$description,$idCar]);

Here all it's equals than before. So, how can you see what print_r it's displaying?

After executing your response on your Android application, you can put these two lines:

HttpEntity entity = response.getEntity();
String responseText = EntityUtils.toString(entity);

And then you can put a Log to see what it's displaying:

Log.d("response",responseText);

Now you will be able to see what print_r it's displaying.

Comments