Need use of the php eval function. Re-enable it plz

Game development with Board Game Arena Studio
Post Reply
User avatar
bidulpik
Posts: 79
Joined: 17 November 2011, 09:02

Need use of the php eval function. Re-enable it plz

Post by bidulpik »

Hi,
in the backgammon possible moves recursive function I need to use the PHP eval function

Code: Select all

       
       		$txt = '$recursiveMoves';
                for ($i=0; $i < count($newFrom); $i++) {
                    $txt = $txt.'[$newFrom['.$i.']]';
                }
                $txt .= '["detail"] = $moveDetails;';
                eval($txt);
It was available before. Can you re-allow it plz ?

It is really inconvenient to spend time reviewing code that was accepted before.

best regards
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: Need use of the php eval function. Re-enable it plz

Post by Tisaac »

No, eval is the root of evil. You don't need eval at all here (or ever), just use php reference for instance to achieve the same in your case.
User avatar
bidulpik
Posts: 79
Joined: 17 November 2011, 09:02

Re: Need use of the php eval function. Re-enable it plz

Post by bidulpik »

HI,
yes but how can you do that with PHP reference ?
regards
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: Need use of the php eval function. Re-enable it plz

Post by Tisaac »

bidulpik wrote: 06 March 2022, 13:33 HI,
yes but how can you do that with PHP reference ?
regards
Have you read the doc about php ref ?
The code is basically the same, you just need to remove the quote and use & whenevr you access a sub element of an array to make sure it's not implicitely copied by php but rather modifying the original array
Post Reply

Return to “Developers”