L
L
Leonid2021-05-16 16:05:10
JavaScript
Leonid, 2021-05-16 16:05:10

PHP8 comparing numbers in a string?

Earlier if you write

$test = "test";
if($test>0) echo "number";
else echo "not number";

then it will give out not number

Now in PHP8 it has become stricter comparison
tried gives out Number

e unfortunately in old projects such comparisons come across because it is shorter than is_integer
to catch by code analysis only when the program is running

Maybe there is some option in the new PHP that makes the comparison as before?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Gilfy, 2018-11-27
@liggth

You most likely didn't download the required library
https://developers.google.com/chart/interactive/do...
Working example:
jsfiddle.net/9ojr0gdz

P
profesor08, 2021-05-16
@profesor08

Why write such code in the first place? Now suffer, and manually catch all the shit that you have coded in projects. Either sit on the previous version of php, and already do new projects on the new one.
And there is also https://psalm.dev/ to catch any shit, it should help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question