Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP system("cd \"); not working

i used to use system commands through a php file ..cd \ was working then suddenly after a few tries it stopped :| no matter what i do

<?php
    $command = array("cd \","dir"); 
    $result = system($command[0], $return);
?>
like image 374
kapitanluffy Avatar asked Feb 25 '26 18:02

kapitanluffy


2 Answers

Windows support forward slashes / as well as backslashes \ so by using just forward slashes you should be cross compatible and less aggravation in the long run.

<?php
    $command = array("cd /","dir");
    $result = system($command[0], $return);
?>

Wiki Path_Computing


If you have any errors then please post them as the issue may not be the directory slashing because you said it was previously working.

like image 193
RobertPitt Avatar answered Feb 28 '26 06:02

RobertPitt


Try

$command = array("cd \\","dir"); 
like image 39
Andreas Wong Avatar answered Feb 28 '26 07:02

Andreas Wong