-2

I'm new in PHP. I run file.php on my PC with Firefox but I don't know how see error. What I can add to see it, is possible if I have this file on pc and not on server?

Maybe this:

error_reporting(E_ALL);
ini_set('display_errors', 1);

or it works only on Apache?

I tried nothing because I don't know how solve it.

This my file.php

<?php
 include('wrapper.php');
 $apikey = "xxx7d7391d1e68e9680e6";
 voxmail_init($apikey);
 voxmail_user_subscribe(array('mail' => 'xxxxx@gmail.com','privacy' => 1));
?>

This file used api newsletter service (the code - for assistance of service - is ok) and voxmail_user_subscribe register the email address at newsletter. wrapper.php is file in same folder of file.php for use API of this service.

In this wrapper.php is there include other file xmlrpc.inc (also in same folder)

Now when I run file.php in my browser the only thing that I see is this:

**'xxxx@gmail.com','privacy' => 1));?>**

but the assistant servec tried my code and works... he ask me to show error log, but I don't know where is this log.

halfer
  • 19,824
  • 17
  • 99
  • 186
Borja
  • 3,359
  • 7
  • 33
  • 66

2 Answers2

1

Those directives can be set in lots of different places, as explained at Runtime Configuration. You need to be aware of the different syntaxes:

  • If you set them from PHP code, you have to compose valid PHP code, e.g.:

    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', true);
    
  • If you set it in PHP configuration files (php.ini or .user.ini) you have to use valid *.ini syntax:

    error_reporting = E_ALL
    display_errors = On
    
  • If you set it in Apache configuration files (httpd.conf or .htaccess) you have to use valid apache syntax:

    php_value error_reporting E_ALL
    php_flag display_errors On
    

It's worth noting that errors that prevent PHP code from running (such as parse errors) cannot be set from within PHP code.

My advice is to configure your local system-wide file for development (display all errors, log none) and configure your project for dual configuration (display in development, log in production).


Answer to updated question:

  1. can't see any obvious reason why your code should trigger errors and notices. Are you sure it does? Have you tried with something that should trigger one such as 1/0;?

  2. If you can see PHP code in the browser, your code is not running at all.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
1

Example

error_log("You messed up!", 3, "/var/tmp/my-errors.log");

You can use

error_log — Send an error message somewhere

Panayiotis Georgiou
  • 1,135
  • 3
  • 19
  • 36