1

Hello i'm having some troubles with phantomjs. Im trying execute a simple statement but im getting the same error over and over.

exec('../bin/phantomjs --version', $o, $r);
var_dump($r);

print_r($o);

im getting this:

int(2) Array ( [0] => ../bin/phantomjs: 1: ../bin/phantomjs: Syntax error: Unterminated quoted string )

What gives? Im on a mac and phantomjs have 777 rights.

J.Wennergren
  • 145
  • 14

1 Answers1

0

It means there is a syntax error in your script, a missing " symbol somewhere. Check your script, for example here: http://esprima.org/demo/validate.html or in an editor with syntax validation and fix any errors found.

It's a good idea to also test PhantomJS script after changes from a console before running in any external service (like PHP).

Vaviloff
  • 16,282
  • 6
  • 48
  • 56
  • Hello, thanks for you answer. Right now im not running any scripts im just doing that in a phpfile. It works when i run phantomjs --version in my console. but not through PHPs exec function. – J.Wennergren Feb 12 '18 at 12:59
  • Update: I tried to pull out my code into a seperate file and execute it with php in console and it works. When i put my code back into my documents/code directory it doesnt work anymore. – J.Wennergren Feb 12 '18 at 13:20
  • Please update the answer with information on paths: where your php script is, where PhantomJS script is, what paths you put into `exec` command, and lastly, what exact error occurs. – Vaviloff Feb 13 '18 at 07:40