0

I'm running PHP version 7.0.2 on OS X El Capitan and every time I execute a PHP script that contains some erroneous code, it reports the error and then seems to perform a backtrace automatically. I'm not so sure if this is a new feature in PHP 7, however I cannot seem to find mention of it anywhere or anyone else who's facing a similar problem.

For Example:

<?php
   echo $a;
?>

Will return the following output if executed from CLI:

PHP Notice:  Undefined variable: a in /Path/to/file.php on line 2
PHP Stack trace:
PHP   1. {main}() /Path/to/file.php:0

Notice: Undefined variable: a in /Path/to/file.php on line 2

Call Stack:
    0.0002     350944   1. {main}() /Path/to/file.php:0

Any insight on what might be causing the problem is welcome. Thanks.

4
  • How is this a problem? I get the same info with php 5.6.10 on my computer. PHP7 might have improved it a bit, but it's not new. And it's a good thing! Commented Mar 3, 2016 at 3:05
  • jszobody The main reason I want to disable it is because I'm trying to migrate a fairly large project from PHP 5.6 and a large number of PHP Stack Trace statements seem to flood my terminal making it extremely difficult to sift through by comparison to what it's normal activity is to me. I suppose a better question is, is there a way to disable this? Commented Mar 3, 2016 at 3:09
  • Sure. Look at php.net/manual/en/function.error-reporting.php. You want to disable notices, most likely. Probably strict too. Commented Mar 3, 2016 at 3:10
  • posted as an answer. thanks. Commented Mar 3, 2016 at 3:19

2 Answers 2

1

The problem I was facing was not with PHP 7.0.2 itself, but with an extension that had somehow become enabled called XDebug. XDebug which is intended for advanced error reporting was causing problems in another project of mine and by disabling it, it seemed to solve my problem. In order to disable XDebug all you need to do is modify your php.ini file and change the values debug.remote_autostart, debug.default_enable, and debug.remote_enable from 'on' to 'off'.

Sign up to request clarification or add additional context in comments.

1 Comment

It's too bad you have to disable XDebug. I can't imagine life without it on my dev server!
0

Adding xdebug.default_enable=0 to php.ini will prevent XDebug from sending stack traces without giving up profiling and debugging capabilities.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.