Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The return value of function %s() should either be used or intentionally ignored by casting it as (void)%S code

Description

.

Example

<?php

#[NoDiscard]
function foo() {
    return 1;
}

foo();

?>

Literal Examples

  • The return value of function foo() should either be used or intentionally ignored by casting it as (void)

Alternatives

  • Add the (void) cast to the function call, so as to ignore the returned value.
  • Store the result of the function call in a variable and use it.

Changed Behavior

This error may appear following an evolution in behavior, in previous versions. See