SlideShare a Scribd company logo
PHP 7.0'S
ERROR MESSAGES
HAVING FUN WITH ERRORS
PHPAmersfoort
AGENDA
• 2229 error messages to review
• New gotchas
• New features, new messages
SPEAKER
• Damien Seguy
• CTO at exakat
• "Ik ben een boterham" : I'm a resident
• Automated code audit services
EVOLUTION OF ERROR MESSAGES
SEARCHING FOR MESSAGES
• PHP-src repository
• zend_error
• zend_throw
• zend_throw_exception
• zend_error_throw
TOP 5 (FROM THE SOURCE)
1. Using $this when not in object context (192)
2. Cannot use string offset as an array (74)
3. Cannot use string offset as an object (56)
4. Only variable references should be yielded by
reference (52)
5. Undefined variable: %s (43)
TOP 5 (GOOGLE)
1. Call to undefined function
2. Class not found
3. Allowed memory size of
4. Undefined index
5. Undefined variable
EXCEPTIONS ARE ON THE RISE
AGENDA
• New error messages (New features)
• Better linting
• Removed messages
• Cryptic messages
NEW FEATURES
RETURN VALUE OF %S%S%S()
MUST %S%S, %S%S RETURNED
<?php   
  function x(): array {  
   return false;  
} 
   
?>
Uncaught TypeError: Return value of x() must be of the type array,
boolean returned in
RETURN VALUE OF %S%S%S()
MUST %S%S, %S%S RETURNED
<?php   
  function x(): array {  
   return ;  
  } 
   
?>
Uncaught TypeError: Return value of x() must be of the type array,
none returned in
ARGUMENT %D PASSED TO %S%S%S() MUST
%S%S, %S%S GIVEN, CALLED IN %S ON LINE
%D
<?php   
function x(array $a)  {  
  return false;  
} 
x(false); 
   
?>
Uncaught TypeError: Argument 1 passed to x() must be of the type
array, boolean given, called in
DEFAULT VALUE FOR PARAMETERS WITH
A FLOAT TYPE HINT CAN ONLY BE FLOAT
<?php   
    function foo(float $a = "3"){  
        return true;  
    }  
?> 
DEFAULT VALUE FOR PARAMETERS WITH
A FLOAT TYPE HINT CAN ONLY BE FLOAT
<?php   
    function foo(float $a =  3 ){  
        return true;  
    }  
?> 
CANNOT USE TEMPORARY
EXPRESSION IN WRITE CONTEXT
<?php  
'foo'[0] = 'b';  
?>
CANNOT USE TEMPORARY
EXPRESSION IN WRITE CONTEXT
<?php   
$a = 'foo';  
$a[0] = 'b';   
print $a;  
?>
CANNOT USE "%S" WHEN NO
CLASS SCOPE IS ACTIVE
<?php    
  function x(): parent {   
    return new bar();  
 }  
x();  
?>
• self
• parent
• static
CANNOT USE "%S" WHEN NO
CLASS SCOPE IS ACTIVE
<?php    
class bar extends baz {}   
class foo extends bar {  
  function x(): parent {   
    return new foo();  
 }  
}  
$x = new foo();  $x->x();  
?>
CANNOT USE "%S" WHEN NO
CLASS SCOPE IS ACTIVE
<?php    
class bar extends baz {}   
class foo extends bar {  
  function x(): parent {   
    return new bar();  
 }  
}  
$x = new foo();  $x->x();  
?>
CANNOT USE "%S" WHEN NO
CLASS SCOPE IS ACTIVE
<?php    
class baz {}   
class bar extends baz {}   
class foo extends bar {  
  function x(): parent {   
    return new baz();  
 }  
}  
$x = new foo(); $x->x();  
?>Uncaught TypeError: Return value of foo::x() must be an instance of
bar, instance of baz returned in
CANNOT USE "%S" WHEN NO
CLASS SCOPE IS ACTIVE
<?php    
class baz {}   
class bar extends baz {}   
class foo extends bar {  
  function x(): grandparent {   
    return new baz();  
 }  
}  
$x = new foo(); $x->x();  
?>Uncaught TypeError: Return value of foo::x() must be an instance of
grandparent, instance of bar returned
CANNOT DECLARE A RETURN
TYPE
• __construct
• __destruct
• __clone
• "PHP 4 constructor"
<?php   
class x {  
    function __construct() : array {  
        return true;  
    }  
    function x() : array {  
        return true;  
    }  
}  
?>
METHODS WITH THE SAME NAME AS THEIR CLASS
WILL NOT BE CONSTRUCTORS IN A FUTURE VERSION
OF PHP; %S HAS A DEPRECATED CONSTRUCTOR
<?php   
class x {  
    function x() : array {  
        return true;  
    }  
}  
?>
INVALID UTF-8 CODEPOINT
ESCAPE SEQUENCE
我爱你
<?php   
$a = "u{6211}u{7231}u{4f60}";  
echo $a;  
?> 
INVALID UTF-8 CODEPOINT
ESCAPE SEQUENCE
• Incompatible with PHP 5.6
• Good for literals
• Alternatives?
<?php   
$a = "u{de";  
echo $a;  
?> 
<?php  
echo mb_convert_encoding('&#x'.$unicode.';', 'UTF-8', 'HTML-ENTITIES');  
echo json_decode('"u'.$unicode.'"');  
echo html_entity_decode('&#'.hexdec($unicode).';', 0, 'UTF-8');  
     eval('"u{'.$unicode.'}n"');  
?>
NEW LINTING
A CLASS CONSTANT MUST NOT BE CALLED 'CLASS';
IT IS RESERVED FOR CLASS NAME FETCHING
• Used to be a parse error. Now a nice message.
• Still rarely useful
<?php   
class x {  
    const class = 1;  
}  
?>
A CLASS CONSTANT MUST NOT BE CALLED 'CLASS';
IT IS RESERVED FOR CLASS NAME FETCHING
• Used to be a parse error. Now a nice message.
• Still rarely useful
• Outside class will 

generate

the old error
<?php   
//class x {  
    const class = 1;  
//}  
?>
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting
identifier (T_STRING)
DYNAMIC CLASS NAMES ARE NOT
ALLOWED IN COMPILE-TIME ::CLASS FETCH
<?php    
$c = new class { 
function f() { 
echo $x::class; 
}
}; 
$c->f(); 
?>
REDEFINITION OF PARAMETER
$%S
<?php  
function foo($a, $a, $a) {  
  echo "$an";  
}  
foo(1,2,3);  
?>
SWITCH STATEMENTS MAY ONLY
CONTAIN ONE DEFAULT CLAUSE
<?php   
switch($x) {   
    case '1' :    
        break;   
    default :    
        break;   
    default :    
        break;   
    case '2' :    
        break;   
}   
?>
SWITCH STATEMENTS MAY ONLY
CONTAIN ONE DEFAULT CLAUSE
<?php   
switch($x) {   
    case 1 :    
        break;   
    case 0+1 :    
        break;   
    case '1' :    
        break;   
    case true :    
        break;   
    case 1.0 :    
        break;   
    case $y :    
        break;   
EXCEPTIONS MUST IMPLEMENT
THROWABLE
<?php    
throw new stdClass();
?> 
Fatal error: Uncaught Error: Cannot throw objects that do not
implement Throwable
EXCEPTIONS MUST IMPLEMENT
THROWABLE
<?php    
class e implements Throwable {
/* Methods */
 public function  getMessage() {}
 public function  getCode() {}
 public function  getFile() {}
 public function  getLine() {}
 public function  getTrace() {}
 public function  getTraceAsString() {}
 public function  getPrevious() {}
 public function  __toString() {}
}
?> 
Class e cannot implement interface Throwable, extend Exception or
Error instead
RETIRED MESSAGES
FATAL ERROR
<?php 
interface t{} 
trait t{} 
?>
Fatal error: Cannot redeclare class t in
CALL-TIME PASS-BY-REFERENCE
HAS BEEN REMOVED;
<?php  
$a = 3;  
function f($b) {  
    $b++;  
}  
f(&$a);  
print $a;  
?>
Fatal error: Call-time pass-by-reference has been removed; If you
would like to pass argument by reference, modify the declaration of
f(). in
HAS BEEN REMOVE
CALL-TIME PASS-BY-REFERENCE
HAS BEEN REMOVED;
<?php  
$a = 3;  
function f($b) {  
    $b++;  
}  
f(&$a);  
print $a;  
?>
PHP Parse error: syntax error, unexpected '&' in
CRYPTIC MESSAGES
MINIMUM VALUE MUST BE LESS THAN
OR EQUAL TO THE MAXIMUM VALUE
<?php 
var_dump(random_int(100, 999)); 
var_dump(random_int(-1000, 0)); 
var_dump(random_bytes(10)); 
?>
DIVISION OF PHP_INT_MIN BY
-1 IS NOT AN INTEGER
• PHP_INT_MIN is the smallest integer on PHP
• PHP_INT_MAX : 9223372036854775807
• PHP_INT_MIN : -9223372036854775808
• Division or multiplication leads to non-integer
• Uses the Integer Division intdiv()
WEBP DECODE: REALLOC
FAILED
• New image format for the Web
• Lossless compression, small files
• gdImageCreateFromWebpCtx emit this
• Probably very bad
FUNCTION NAME MUST BE A
STRING
<?php  
if ($_GET('X') == 'Go') {  
    ProcessFile();  
    return;  
}  
?>
ENCODING DECLARATION
PRAGMA MUST BE THE VERY
FIRST STATEMENT IN THE SCRIPT
NAMESPACE DECLARATION
STATEMENT HAS TO BE THE VERY
FIRST STATEMENT IN THE SCRIPT
NAMESPACE DECLARATION
STATEMENT HAS TO BE THE VERY
FIRST STATEMENT IN THE SCRIPT
ENCODING DECLARATION
PRAGMA MUST BE THE VERY
FIRST STATEMENT IN THE SCRIPT
<?php 
declare(encoding='ISO-8859-1'); 
namespace myNamespace; 
// code here 
// --enable-zend-multibyte
?>
FIRST STATEMENT EVER
YOU SEEM TO BE TRYING TO
USE A DIFFERENT LANGUAGE...
<?php  
use strict;
WHAT ABOUT MY CODE?
FUN WITH ERRORS
• Check the errors messages in your application
• die, exit
• echo, print, display, debug, wp_die

(depends on conventions)
• new *Exception()
• What does your application tells you?
• die('I SEE ' . $action . ' - ' . $_POST['categories_id']);
• die("Error: application_top not found.nMake sure you have placed the
currency_cron.php file in your (renamed) Admin folder.nn");
• die('ERROR: admin/includes/configure.php file not found. Suggest running
zc_install/index.php?');
• die('I WOULD NOT ADD ' . $new_categories_sort_array[$i] . '<br>');
• die('NOTCONFIGURED');
• die('halted');
• die('<pre>' . print_r($inputs, true));
• die('HERE_BE_MONSTERS - could not open file');}
• die('HERE_BE_MONSTERS');}
• die($prod_id);
• die('here');
• die('Sorry. File not found. Please contact the webmaster to report this
error.<br />c/f: ' . $origin_filename);
DANK U WEL
@EXAKAT

More Related Content

PDF
errors in php 7
PDF
Just-In-Time Compiler in PHP 8
PDF
Cli the other SAPI confoo11
PDF
What's new in PHP 8.0?
PDF
Static Optimization of PHP bytecode (PHPSC 2017)
PDF
CLI, the other SAPI phpnw11
PDF
Cli the other sapi pbc11
PDF
PHP 7 – What changed internally? (PHP Barcelona 2015)
errors in php 7
Just-In-Time Compiler in PHP 8
Cli the other SAPI confoo11
What's new in PHP 8.0?
Static Optimization of PHP bytecode (PHPSC 2017)
CLI, the other SAPI phpnw11
Cli the other sapi pbc11
PHP 7 – What changed internally? (PHP Barcelona 2015)

What's hot (20)

PDF
Nikita Popov "What’s new in PHP 8.0?"
PDF
PHP 良好實踐 (Best Practice)
PDF
SPL: The Missing Link in Development
PPTX
PHP Basics
PPT
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
PPT
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
PDF
PHP Conference Asia 2016
PPT
Php i basic chapter 3
PDF
PHP Enums - PHPCon Japan 2021
PPTX
New in php 7
PDF
Typed Properties and more: What's coming in PHP 7.4?
PPT
Basic PHP
PDF
Preparing for the next PHP version (5.6)
KEY
SPL, not a bridge too far
PPT
Introduction to php
PDF
PHP 8.1 - What's new and changed
PPTX
A Functional Guide to Cat Herding with PHP Generators
PDF
Overview changes in PHP 5.4
PDF
Data Types In PHP
KEY
Workshop unittesting
Nikita Popov "What’s new in PHP 8.0?"
PHP 良好實踐 (Best Practice)
SPL: The Missing Link in Development
PHP Basics
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
PHP Conference Asia 2016
Php i basic chapter 3
PHP Enums - PHPCon Japan 2021
New in php 7
Typed Properties and more: What's coming in PHP 7.4?
Basic PHP
Preparing for the next PHP version (5.6)
SPL, not a bridge too far
Introduction to php
PHP 8.1 - What's new and changed
A Functional Guide to Cat Herding with PHP Generators
Overview changes in PHP 5.4
Data Types In PHP
Workshop unittesting
Ad

Similar to Php 7 errors messages (20)

PDF
Preparing for the next php version
PPTX
Migrating to PHP 7
PDF
Review unknown code with static analysis - bredaphp
PPTX
PHP7 Presentation
PPTX
Peek at PHP 7
PPTX
PHP 7 - A look at the future
PPTX
PHP7 - A look at the future
PDF
Php 7 compliance workshop singapore
PDF
Giới thiệu PHP 7
PDF
Php 7.2 compliance workshop php benelux
PDF
PHP 7.0 new features (and new interpreter)
PDF
Hunt for dead code
PDF
Last train to php 7
PDF
PHP7 is coming
ODP
The why and how of moving to php 7.x
ODP
The why and how of moving to php 7.x
PDF
What To Expect From PHP7
PDF
Clear php reference
PDF
PHP7: Hello World!
PDF
Preparing code for Php 7 workshop
Preparing for the next php version
Migrating to PHP 7
Review unknown code with static analysis - bredaphp
PHP7 Presentation
Peek at PHP 7
PHP 7 - A look at the future
PHP7 - A look at the future
Php 7 compliance workshop singapore
Giới thiệu PHP 7
Php 7.2 compliance workshop php benelux
PHP 7.0 new features (and new interpreter)
Hunt for dead code
Last train to php 7
PHP7 is coming
The why and how of moving to php 7.x
The why and how of moving to php 7.x
What To Expect From PHP7
Clear php reference
PHP7: Hello World!
Preparing code for Php 7 workshop
Ad

More from Damien Seguy (20)

PDF
Strong typing @ php leeds
PPTX
Strong typing : adoption, adaptation and organisation
PDF
Qui a laissé son mot de passe dans le code
PDF
Analyse statique et applications
PDF
Top 10 pieges php afup limoges
PDF
Top 10 php classic traps DPC 2020
PDF
Meilleur du typage fort (AFUP Day, 2020)
PDF
Top 10 php classic traps confoo
PDF
Tout pour se préparer à PHP 7.4
PDF
Top 10 php classic traps php serbia
PDF
Top 10 php classic traps
PDF
Top 10 chausse trappes
PDF
Code review workshop
PDF
Understanding static analysis php amsterdam 2018
PDF
Review unknown code with static analysis php ce 2018
PDF
Everything new with PHP 7.3
PDF
Php 7.3 et ses RFC (AFUP Toulouse)
PDF
Tout sur PHP 7.3 et ses RFC
PDF
Review unknown code with static analysis php ipc 2018
PDF
Code review for busy people
Strong typing @ php leeds
Strong typing : adoption, adaptation and organisation
Qui a laissé son mot de passe dans le code
Analyse statique et applications
Top 10 pieges php afup limoges
Top 10 php classic traps DPC 2020
Meilleur du typage fort (AFUP Day, 2020)
Top 10 php classic traps confoo
Tout pour se préparer à PHP 7.4
Top 10 php classic traps php serbia
Top 10 php classic traps
Top 10 chausse trappes
Code review workshop
Understanding static analysis php amsterdam 2018
Review unknown code with static analysis php ce 2018
Everything new with PHP 7.3
Php 7.3 et ses RFC (AFUP Toulouse)
Tout sur PHP 7.3 et ses RFC
Review unknown code with static analysis php ipc 2018
Code review for busy people

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
sap open course for s4hana steps from ECC to s4
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Spectroscopy.pptx food analysis technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
cuic standard and advanced reporting.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
MYSQL Presentation for SQL database connectivity
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
sap open course for s4hana steps from ECC to s4
MIND Revenue Release Quarter 2 2025 Press Release
Spectroscopy.pptx food analysis technology
Reach Out and Touch Someone: Haptics and Empathic Computing
NewMind AI Weekly Chronicles - August'25 Week I
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
cuic standard and advanced reporting.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Network Security Unit 5.pdf for BCA BBA.
Building Integrated photovoltaic BIPV_UPV.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Chapter 3 Spatial Domain Image Processing.pdf
Programs and apps: productivity, graphics, security and other tools
Understanding_Digital_Forensics_Presentation.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf

Php 7 errors messages

  • 1. PHP 7.0'S ERROR MESSAGES HAVING FUN WITH ERRORS PHPAmersfoort
  • 2. AGENDA • 2229 error messages to review • New gotchas • New features, new messages
  • 3. SPEAKER • Damien Seguy • CTO at exakat • "Ik ben een boterham" : I'm a resident • Automated code audit services
  • 5. SEARCHING FOR MESSAGES • PHP-src repository • zend_error • zend_throw • zend_throw_exception • zend_error_throw
  • 6. TOP 5 (FROM THE SOURCE) 1. Using $this when not in object context (192) 2. Cannot use string offset as an array (74) 3. Cannot use string offset as an object (56) 4. Only variable references should be yielded by reference (52) 5. Undefined variable: %s (43)
  • 7. TOP 5 (GOOGLE) 1. Call to undefined function 2. Class not found 3. Allowed memory size of 4. Undefined index 5. Undefined variable
  • 8. EXCEPTIONS ARE ON THE RISE
  • 9. AGENDA • New error messages (New features) • Better linting • Removed messages • Cryptic messages
  • 11. RETURN VALUE OF %S%S%S() MUST %S%S, %S%S RETURNED <?php      function x(): array {      return false;   }      ?> Uncaught TypeError: Return value of x() must be of the type array, boolean returned in
  • 12. RETURN VALUE OF %S%S%S() MUST %S%S, %S%S RETURNED <?php      function x(): array {      return ;     }      ?> Uncaught TypeError: Return value of x() must be of the type array, none returned in
  • 13. ARGUMENT %D PASSED TO %S%S%S() MUST %S%S, %S%S GIVEN, CALLED IN %S ON LINE %D <?php    function x(array $a)  {     return false;   }  x(false);      ?> Uncaught TypeError: Argument 1 passed to x() must be of the type array, boolean given, called in
  • 14. DEFAULT VALUE FOR PARAMETERS WITH A FLOAT TYPE HINT CAN ONLY BE FLOAT <?php        function foo(float $a = "3"){           return true;       }   ?> 
  • 15. DEFAULT VALUE FOR PARAMETERS WITH A FLOAT TYPE HINT CAN ONLY BE FLOAT <?php        function foo(float $a =  3 ){           return true;       }   ?> 
  • 16. CANNOT USE TEMPORARY EXPRESSION IN WRITE CONTEXT <?php   'foo'[0] = 'b';   ?>
  • 17. CANNOT USE TEMPORARY EXPRESSION IN WRITE CONTEXT <?php    $a = 'foo';   $a[0] = 'b';    print $a;   ?>
  • 18. CANNOT USE "%S" WHEN NO CLASS SCOPE IS ACTIVE <?php       function x(): parent {        return new bar();    }   x();   ?> • self • parent • static
  • 19. CANNOT USE "%S" WHEN NO CLASS SCOPE IS ACTIVE <?php     class bar extends baz {}    class foo extends bar {     function x(): parent {        return new foo();    }   }   $x = new foo();  $x->x();   ?>
  • 20. CANNOT USE "%S" WHEN NO CLASS SCOPE IS ACTIVE <?php     class bar extends baz {}    class foo extends bar {     function x(): parent {        return new bar();    }   }   $x = new foo();  $x->x();   ?>
  • 21. CANNOT USE "%S" WHEN NO CLASS SCOPE IS ACTIVE <?php     class baz {}    class bar extends baz {}    class foo extends bar {     function x(): parent {        return new baz();    }   }   $x = new foo(); $x->x();   ?>Uncaught TypeError: Return value of foo::x() must be an instance of bar, instance of baz returned in
  • 22. CANNOT USE "%S" WHEN NO CLASS SCOPE IS ACTIVE <?php     class baz {}    class bar extends baz {}    class foo extends bar {     function x(): grandparent {        return new baz();    }   }   $x = new foo(); $x->x();   ?>Uncaught TypeError: Return value of foo::x() must be an instance of grandparent, instance of bar returned
  • 23. CANNOT DECLARE A RETURN TYPE • __construct • __destruct • __clone • "PHP 4 constructor" <?php    class x {       function __construct() : array {           return true;       }       function x() : array {           return true;       }   }   ?>
  • 24. METHODS WITH THE SAME NAME AS THEIR CLASS WILL NOT BE CONSTRUCTORS IN A FUTURE VERSION OF PHP; %S HAS A DEPRECATED CONSTRUCTOR <?php    class x {       function x() : array {           return true;       }   }   ?>
  • 25. INVALID UTF-8 CODEPOINT ESCAPE SEQUENCE 我爱你 <?php    $a = "u{6211}u{7231}u{4f60}";   echo $a;   ?> 
  • 26. INVALID UTF-8 CODEPOINT ESCAPE SEQUENCE • Incompatible with PHP 5.6 • Good for literals • Alternatives? <?php    $a = "u{de";   echo $a;   ?>  <?php   echo mb_convert_encoding('&#x'.$unicode.';', 'UTF-8', 'HTML-ENTITIES');   echo json_decode('"u'.$unicode.'"');   echo html_entity_decode('&#'.hexdec($unicode).';', 0, 'UTF-8');        eval('"u{'.$unicode.'}n"');   ?>
  • 28. A CLASS CONSTANT MUST NOT BE CALLED 'CLASS'; IT IS RESERVED FOR CLASS NAME FETCHING • Used to be a parse error. Now a nice message. • Still rarely useful <?php    class x {       const class = 1;   }   ?>
  • 29. A CLASS CONSTANT MUST NOT BE CALLED 'CLASS'; IT IS RESERVED FOR CLASS NAME FETCHING • Used to be a parse error. Now a nice message. • Still rarely useful • Outside class will 
 generate
 the old error <?php    //class x {       const class = 1;   //}   ?> Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING)
  • 30. DYNAMIC CLASS NAMES ARE NOT ALLOWED IN COMPILE-TIME ::CLASS FETCH <?php     $c = new class {  function f() {  echo $x::class;  } };  $c->f();  ?>
  • 32. SWITCH STATEMENTS MAY ONLY CONTAIN ONE DEFAULT CLAUSE <?php    switch($x) {        case '1' :             break;        default :             break;        default :             break;        case '2' :             break;    }    ?>
  • 33. SWITCH STATEMENTS MAY ONLY CONTAIN ONE DEFAULT CLAUSE <?php    switch($x) {        case 1 :             break;        case 0+1 :             break;        case '1' :             break;        case true :             break;        case 1.0 :             break;        case $y :             break;   
  • 34. EXCEPTIONS MUST IMPLEMENT THROWABLE <?php     throw new stdClass(); ?>  Fatal error: Uncaught Error: Cannot throw objects that do not implement Throwable
  • 38. CALL-TIME PASS-BY-REFERENCE HAS BEEN REMOVED; <?php   $a = 3;   function f($b) {       $b++;   }   f(&$a);   print $a;   ?> Fatal error: Call-time pass-by-reference has been removed; If you would like to pass argument by reference, modify the declaration of f(). in HAS BEEN REMOVE
  • 39. CALL-TIME PASS-BY-REFERENCE HAS BEEN REMOVED; <?php   $a = 3;   function f($b) {       $b++;   }   f(&$a);   print $a;   ?> PHP Parse error: syntax error, unexpected '&' in
  • 41. MINIMUM VALUE MUST BE LESS THAN OR EQUAL TO THE MAXIMUM VALUE <?php  var_dump(random_int(100, 999));  var_dump(random_int(-1000, 0));  var_dump(random_bytes(10));  ?>
  • 42. DIVISION OF PHP_INT_MIN BY -1 IS NOT AN INTEGER • PHP_INT_MIN is the smallest integer on PHP • PHP_INT_MAX : 9223372036854775807 • PHP_INT_MIN : -9223372036854775808 • Division or multiplication leads to non-integer • Uses the Integer Division intdiv()
  • 43. WEBP DECODE: REALLOC FAILED • New image format for the Web • Lossless compression, small files • gdImageCreateFromWebpCtx emit this • Probably very bad
  • 44. FUNCTION NAME MUST BE A STRING <?php   if ($_GET('X') == 'Go') {       ProcessFile();       return;   }   ?>
  • 45. ENCODING DECLARATION PRAGMA MUST BE THE VERY FIRST STATEMENT IN THE SCRIPT
  • 46. NAMESPACE DECLARATION STATEMENT HAS TO BE THE VERY FIRST STATEMENT IN THE SCRIPT
  • 47. NAMESPACE DECLARATION STATEMENT HAS TO BE THE VERY FIRST STATEMENT IN THE SCRIPT ENCODING DECLARATION PRAGMA MUST BE THE VERY FIRST STATEMENT IN THE SCRIPT
  • 49. YOU SEEM TO BE TRYING TO USE A DIFFERENT LANGUAGE... <?php   use strict;
  • 50. WHAT ABOUT MY CODE?
  • 51. FUN WITH ERRORS • Check the errors messages in your application • die, exit • echo, print, display, debug, wp_die
 (depends on conventions) • new *Exception() • What does your application tells you?
  • 52. • die('I SEE ' . $action . ' - ' . $_POST['categories_id']); • die("Error: application_top not found.nMake sure you have placed the currency_cron.php file in your (renamed) Admin folder.nn"); • die('ERROR: admin/includes/configure.php file not found. Suggest running zc_install/index.php?'); • die('I WOULD NOT ADD ' . $new_categories_sort_array[$i] . '<br>'); • die('NOTCONFIGURED'); • die('halted'); • die('<pre>' . print_r($inputs, true)); • die('HERE_BE_MONSTERS - could not open file');} • die('HERE_BE_MONSTERS');} • die($prod_id); • die('here'); • die('Sorry. File not found. Please contact the webmaster to report this error.<br />c/f: ' . $origin_filename);