doubipeng1336 2016-10-12 01:36
浏览 128
已采纳

如何在Windows CLI中运行PHP脚本

I used linux for years but I got a new laptop and haven't bothered to install linux on it yet, instead I've been getting to know Windows better. cmd.exe is absolutely horrific, its so bad I regularly feel like switching back to linux. I can't use it at all. I use PowerShell instead but even thats pretty bad.

With the linux CLIs like bash, when I run a PHP script with a loop, and echo something inside the loop, it will output what I echoed onto the screen with each iteration. PowerShell doesn't do this, it just displays nothing until the script has finished running. I run a lot of web scrapers so this is a big problem for me.

Is there a PHP CLI that I can download that will work better than PowerShell? I also came across an amazing IDE called PHPStorm today, I think it might possibly let you run PHP scripts inside a built in CLI but I haven't figured it out yet. It has a built in web server, but it also lets you add your own web server, and lets you interact with MySQL databases and other impressive things like that.

  • 写回答

2条回答 默认 最新

  • doukenqiong0588 2016-10-19 11:21
    关注

    You can run PHP scripts from the commandline in Windows as well. Given you have a file namned main.php you can run this file by just writing php %filename% (So php main.php) in this case. Anything written to the standard output stream will appear in the console.

    The php binary is not present in the environment path variable by default and should be added.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办