I invented a new incremental game in PHP, check it out;

I invented a new incremental game in PHP, check it out;

$GLOBALCOUNT=mt_rand(10000000, 70000000);
WHILE (1==1){
USLEEP(50000);
$OPERATOR=substr(str_shuffle('-+'), 0, 1);
$NEW=mt_rand(1, 7000000);
$MATH = $GLOBALCOUNT . $OPERATOR . $NEW;
eval('$GLOBALCOUNT='.$MATH.';');
ECHO $GLOBALCOUNT . ' (' . $OPERATOR . $NEW . ') ';
IF ($GLOBALCOUNT < 0) {ECHO LOSS; ECHO PHP_EOL; DIE();}
ECHO PHP_EOL;
}


The goal of the game is not to get below zero. It basically plays itself.

en.wikipedia.org/wiki/Incremental_game

Attached: php-elephant-logo-bd4f9d83be8c8563248fe4793f90bae7.png (1184x742, 43K)

Ain't gonna run that shit.

don't run it it creates mustard gas

Attached: dog.gif (250x313, 2.82M)

> eval
I don't know what is that code, but I was told not to trust a PHP code with eval in it.

>eval()

nice try scholomo

>all the newfags in here who cant code and are too braindead to even read what OP posted

You retards, eval here isn't accepting any input, its just a clever way to implement a randomized math operator. the eval is literally assigning a variable the program created to another variable it created.

>a clever way to implement a randomized math operator
It's not clever, just retarded

> You retards
I don't deny it, in the end, I can't even program in PHP, but I won't trust it.

>retards
>using eval, ever

$globalcount=mt_rand(10000000, 70000000);
while (true) {
usleep(50000);
$neg = (rand(0, 1) * 2 - 1);
$new= mt_rand(1, 7000000);
$globalcount = $globalcount + ($neg * $new);
echo $globalcount . ' (' . ($neg>0?'+':'-') .
$new . ') ';
if ($globalcount < 0) {
echo 'LOSS';
break;
}
echo PHP_EOL;
}

>actually thinking using eval is bad if you're not passing in any form of user input

It is

while youre right, theres no user in put on eval so its okay,

its consideered bad practice, there's a better way to do what youre doing.

But if you insist on being a retard, be my guest

>reinventing the wheel because of peer pressure

isn't that all of Jow Forums though?
>install gentoo
>do it all yourself
>its good that everything breaks, you're learning!

but why is eval even used? why not just writing that statement without eval?

because it works. OP doesn't need to search for another way to do something if his first intuition is perfectly ok. he shouldn't succumb to the taboo and paranoia surrounding a simple function and fix his code when it isn't broken

>because it works
i was literally asking why did he use
eval('$GLOBALCOUNT='.$MATH.';');
and not just
$GLOBALCOUNT= $MATH;

they do the same thing right? am i missing something here ?

$MATH will contain a math operator as a string. by using eval(), that operator gets evaluated as if it were actual code, instead of just assigning a string to that variable.

oh shit thanks and sorry i didnt pay attention to $OPERATOR variable
so i guess its not a big deal he used eval, it saves some complexity if he were to write it without eval

yuh, eval() is only dangerous if theres any chance of ACE, such as when passing in user input or handling GET, POST, or even directory path.