如何在命令行中执行php文件?

如何在命令行中执行php文件?,php,cmd,Php,Cmd,我有1个文件php:C:\\Xml2InDesign\\InDesignTagConverter.php 我通过以下方式执行: $sjis_cmd="php \"C:\\Xml2InDesign\\InDesignTagConverter.php\"; exec($sjis_cmd, $output); 它不起作用。我必须做什么 我从cmd运行: php "C:\Xml2InDesign\InDesignTagConverter.php" "c:\work\link2\\tmp\\5699\\

我有1个文件php:C:\\Xml2InDesign\\InDesignTagConverter.php

我通过以下方式执行:

$sjis_cmd="php \"C:\\Xml2InDesign\\InDesignTagConverter.php\";
exec($sjis_cmd, $output);
它不起作用。我必须做什么

我从cmd运行:

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

显示错误:“php”无法识别…

找到您的php.exe路径并从那里运行命令

例如,如果php.exe位于C:\PHP5\php.exe中,则可以这样执行

C:\PHP5\php.exe "C:\\Xml2InDesign\\InDesignTagConverter.php\"
参考此


如果要通过php代码运行它,请使用命令

是否要从php中执行php文件?你为什么要这么做?而是使用include/require并调用所需的函数。不工作意味着什么。你有错误吗?警告?$output中是否写入了某些内容?我在日志文件中只有命令exe。我在cmd上复制exe。它显示的错误如上所述。
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