Ran into this problem. There is a js roulette system, during the execution of the script, the output of the result is launched and it looks like this:

<span id="result"></span>

As a result, we managed to get this same result using a PHP variable, namely:

$test= '<span id="result" ></span>';
echo 'Number dropped: '.$test.'';

After these steps, the result is written to the test variable and displayed in PHP, but no further actions are performed on this variable.

In the future, it is planned to check whether this very variable test is equal to a number and then perform further actions with it.

if($test== 1)
    echo 'You won this prize';
if($test== 2)
    echo 'You won this prize';

During the execution of this code, nothing happens, that is, the test variable is not checked to see if it is equal to a number. Help to check and further code execution. Thank you very much in advance.

When checking var_dump($test); before id I get the following: string(26) ""

Вадим2022-01-14 17:30:31

Before the first if, for debugging, put var_dump($test); thus, the script will display what is passed to this variable and then you can understand why it does not work. I will assume that you are not passing a number from JS, but an object that contains this number. That's why the check fails.

Медведина2022-01-14 13:57:00

Please provide the complete code. Now it is not very clear how the logic is composed.

Виталий RS2022-01-14 09:23:09