Eric Pruitt
Eric Pruitt

Reputation: 1903

Expand PHP Stack Trace Arguments

On a stack trace returned from a PHP application in development, long string arguments to a function are truncated when display on the error page:

Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO "tb...', Array)

How can I expand the query argument so the full text is visible? The server is running PHP 5.3.3.

Upvotes: 8

Views: 4790

Answers (2)

André Hoffmann
André Hoffmann

Reputation: 3553

Use debug_backtrace instead. It will give you the whole trace and doesn't trim arguments as far as I know.

On a second thought: You might get away with it by either adding a global try catch for the entire application

try {
   ...
} catch (Throwable $e)
   // var_dump($e.$e->getTrace()); // for the local environment
   error_log($e.$e->getTrace()); // for the live environment
}

or by adding a global Exception handler to your application.

Upvotes: 5

Zepporle
Zepporle

Reputation: 443

Starting with PHP 8.0 it is possible to actually raise the limit at which arguments will be truncated.

You can change the newly introduced php.ini setting zend.exception_string_param_max_len and set it to any value between 0 and 1000000, the default being 15.

This only affects stack traces generated using getTraceAsString() or by casting an exception to a string (e.g., by printing it).

More information is available here or in the corresponding RFC.

Upvotes: 5

Related Questions