S
S
swcalc2015-12-10 03:39:19
PHP
swcalc, 2015-12-10 03:39:19

Why doesn't PHP pass a condition that returns 1 (TRUE)?

The result of the work

">>>>> {\"Id\":10,\"owner\":6,\"text\":\"mnogo_texta\",\"date\":\"2015-12-01 13:04:58\",\"status\":1,\"reply_to\":9,\"views\":0} 

<<<<<< !!_!_!(((((1)))))_!__!_!


>>>>> [{\"Id\":14,\"owner\":5,\"text\":\"\mnogo_texta\",\"date\":\"2015-12-01

 13:07:58\",\"status\":1,\"reply_to\":9,\"views\":0},{\"Id\":17,\"owner\":4,\"text\":\mnogo_texta\",\"date\":\"2015-12-01 

14:12:58\",\"status\":1,\"reply_to\":9,\"views\":0}] <<<<<<

Slightly intimidating function code
function surfPost(array $post) {
        $c = '';
        for ($i = 0, $j = 0, $keys = array_keys($post); $given = @$post[$keys[$j]], $i <= count($given); $i++) {
            $c .= '>>>>> ' . json_encode(@$given) . ' <<<<<< ';
            if (@$given[$i] && ($given = $given[$i]) || $j++ && !($i = 0)) {
                $j = $j - 1;
                $c .= '>>>>> ' . @$given['Id'] . ' <<<<<< ';
                break;
            } else {
                $c .= (@$given[$i] && ($given = $given[$i]) || $j++ && !($i = 0)) ? '!!_!_!(((((' . 1 . ')))))_!__!_!' : '!!_!_!(((((' . 0 . ')))))_!__!_!';
            }
        }
        return $c;
    }

The whole point is that this condition gives ELSE, but after that it also displays 1 , why can this happen?
I understand that the code can harm the child's psyche, but somehow.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2015-12-10
@swcalc

Who wrote this nonsense?
What is this:
Should do?
PS
Ok, the problem is clear. Stop writing such crooked code, then there will be no such problems.
Let's look carefully here:

<?php

$j = 0;

if ($j++) {
    echo 1;
} else {
    echo "Else:", $j;
}

And read about php.net/manual/ru/language.operators.increment.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question