Search code examples
phpdirectorysystemcd

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);
?>

Solution

  • I think i figured out the problem.. the system() command in PHP does not create an instance of a cmd.exe instead it only executes the command and exits. that is why when you change directory using CD command ..the directory of the instance created by system() is changed and then exits.i hope my theory is correct xD