0
I’m studying PHP and can’t identify the cause of this error: "Fatal error: strict_types declaration must be the very first statement in the script in C: Users Fernando Onedrive_development_projet PHP index.php on line 8"
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Index - PHP</title>
</head>
<body>
<?php declare(strict_types=1);
function soma($x, $y){
$z = $x + $y;
return $z;
}
?>
</body>
</html>
Could someone give me a hand, please? :)
Try to put the
declare(strict_types=1);
as the first thing in the archive.– lcssanches
I do not understand, I must define "declare()" elsewhere in the scope?
– Fernando Barros
In the same file, in the first row: https://pastebin.com/bPfxbGJa
– lcssanches
Same error, but points to the first line: **"Fatal error: strict_types declaration must be the very first statement in the script in C: Users Fernando Onedrive_development_projet PHP index.php on line 1"**
– Fernando Barros
Here it worked. PHP 7.2. Is your file UTF8? If so, it should be without GOOD
– lcssanches
However, how do I solve this problem?
– Fernando Barros
Exactly as I said. UTF8 file cannot have BOM. On Notepad++ you have the option in the Format to UTF8 menu without BOM: https://www.phpbb.com/kb/images/585_encoding.jpg
– lcssanches
Said and done, it worked @lcssanches, thank you very much!
– Fernando Barros