简体   繁体   English

从命令行运行PHP脚本时出现问题

[英]problems running a PHP script from command line

I'm not sure what i'm doing wrong here. 我不确定我在做什么错。 I've set up the environment variables... and i can do php -v and it'll show me the version. 我已经设置了环境变量...,我可以做php -v,它将显示版本。 However, if i do php blah.php to run a php script i've written, the console returns with no errors and the script is not run? 但是,如果我使用php blah.php来运行我编写的php脚本,则控制台无错误返回且脚本未运行? I know this script works, because i made it a long time ago when i first worked with PHP - however, i don't remember PHP or anything about it at the moment. 我知道这个脚本有效,因为我很久以前第一次使用PHP时就做到了-但是,目前我不记得PHP或任何有关它的内容。

does it have something to do with SET PATH? 它与SET PATH有关吗? I don't see a .bat file in the PHP folder though. 我在PHP文件夹中看不到.bat文件。 Yet, it seems to be working fine when i run php -v... so confused... 然而,当我运行php -v时似乎工作得很好。

Help? 救命? How do i run this script? 如何运行此脚本?

You should use the -f option to execute a file 您应该使用-f选项执行文件

php -f blah.php

It may also be useful to read the help 阅读帮助也可能有用

php -h

try 尝试

php -f blah.php

From php -h 从php -h

-f Parse and execute <file>. -f解析并执行<file>。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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