1
php에서 몇 가지 args를 전달하고 내 js가 읽을 수있는 유일한 arg를 전달하는 간단한 phantomjs 프로그램을 실행하려고합니다. args [0]입니다.Phantomjs는 PHP exec에서 args를 얻지 못합니다.
다음은 코드입니다.
PHP :
...
$resp = exec("phantomjs phantom/test.js hello other args");
...
팬텀/test.js :
이var args = require('system').args;
str = 'Args: ';
args.forEach(function (arg, i) {
str += (i + ': ' + arg);
});
str += ' Length: '+args.length;
str = str.replace(/(\r\n|\n|\r)/gm,"");
console.log(str);
phantom.exit();
출력은 :이 코드를 실행하려고 내가 윈도우 7을 사용하고
Args: 0: phantom/test.js Length: 1
direcly 윈도우 명령 줄에서 (cmd를 -> 'phantomjs test.js 일부 args') 제대로 작동, 그래서, 그 문제는 PHP와 그 거짓말에 있다고 생각 phantomjs의 "require ('system')"과의 관계.
내 끔찍한 영어에 대한 Srry.
고맙습니다.