How to prevent implicit type-conversion in PHP?
I already tried "declare(strict_types=1);" at the very top of the script which is supposed to do the job, but it throws an error telling me that the strict_types declaration must be the first statement in the code. Please have a look at the code for a better understanding. https://code.sololearn.com/wv50ns6LzM1I/?ref=app (Thank you Ipang for your patience!)
8/25/2018 2:53:00 AMKurt Sicht
5 AnswersNew Answer
I also thought it would, but unfortunately it results in the following error message: "Fatal error: strict_types declaration must be the very first statement in the script"
Dababi Mohamed Amine, for some reason it doesn't work for me, but thank you very much for your feedback.
Hi, Strict_types was added in php7. It takes either 1 or 0. If 1, strict type-checking mode is used for function calls and return statements in this file. But you must put it in the first line in your code like this (there is no semicolon): <?php declare(strict_types=1) then your code will run.
the first line should be <?php declare(strict_types=1) php and declare must be in the same line
Actually there is a problem in editor. what u have to do is to copy that code paste it into notepad and than save the file with ANSI encoding. then try to run it hopefully the problem would be resolved