PHP system ("cd \"); does not work

I used system commands through a php file ..cd \, and then suddenly after several attempts to stop it: | no matter what i do

<?php
    $command = array("cd \","dir"); 
    $result = system($command[0], $return);
?>
+3
source share
7 answers

I think I understood the problem. the system () command in PHP does not instantiate cmd.exe; instead, it only executes the command and exits. therefore, when you change the directory using the CD command .. the directory of the instance created by the system () is changed and then exits. I hope my theory is correct xD

+1
source

Windows /, \, , , .

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

Wiki Path_Computing


- , , - , , .

+3

$command = array("cd \\","dir"); 
+2

linux mod:

$command = array("cd \\","dir");

mod:

$command = array("cd /","dir");
0

( Win 7 XP) \ (.. \\ ). . , PHP chdir ?

<?php
    echo getcwd() . "\n";
    chdir("\\");
    echo getcwd() . "\n";
?>

"... cmd ...": . () , . , PHP-, , .

0

(), ?

<?php
$result = system("cd \;".$command[0], $return);?>
0

Source: https://habr.com/ru/post/1777299/


All Articles