How to Escape characters while passing system command in PHP

后端 未结 1 1138
北荒
北荒 2021-01-23 19:56

I have a Linux web server running a PHP/HTML page.

    for loop
    {
    $instruction= \"I\'m constructing the instruction here\";
    }
    $instruction = \"ls         


        
1条回答
  •  后悔当初
    2021-01-23 20:41

    Make use of escapeshellcmd() in PHP

    Something like..

    $escaped_command = escapeshellcmd($command);
    exec($escaped_command);
    

    Alternatively, you could make use of escapeshellarg()

    0 讨论(0)
提交回复
热议问题