简体   繁体   中英

How execute php file in command line?

I have 1 file php: C:\\\\Xml2InDesign\\\\InDesignTagConverter.php

I exe it by:

$sjis_cmd="php \"C:\\Xml2InDesign\\InDesignTagConverter.php\";
exec($sjis_cmd, $output);

It not working. What do i must setting?

I run from cmd:

php "C:\Xml2InDesign\InDesignTagConverter.php" "c:\work\link2\\tmp\\5699\\direction.xml" "c:\work\link2\\tmp\\5699\\tables"

Show error: 'php' is not recognized...

Find your php.exe path and run command from there.

Like if your php.exe is in C:\\PHP5\\php.exe , then you can execute like this

C:\PHP5\php.exe "C:\\Xml2InDesign\\InDesignTagConverter.php\"

Refer this link

OR

if you want to run it through php code then use exec command

The PHP CLI as its called ( php for the Command Line Interface ) is called php.exe It lives in c:\wamp\bin\php\php5.x.y\php.exe ( where x and y are the version numbers of php that you have installed )

If you want to create php scrips to run from the command line that great its easy and very useful.

Create yourself a batch file like this, lets call it phppath.cmd :

PATH=%PATH%;c:\wamp\bin\php\php5.x.y php -v

Save this into one of your folders that is already on your PATH, so you can run it from anywhere.

Now from a command window, cd into your source folder and run >phppath.

Then run

php your_script.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM