dppfxf909679 2016-08-24 23:02
浏览 50
已采纳

我怎样才能让PHP忽略扩展,就像PHPUnit在Windows命令提示符中的做法一样?

On Windows i have the following script in a file called TrelloInt.main.php

<?php

    $importData = file_get_contents("TrelloData\TrelloJsonExport.txt");
    $json = json_decode($importData);
    var_dump($json);

?>

all the file does is var_dump the decoded json object to the screen.

when i open up Command Prompt i use the following script in a batch file

d:
cd "_Work\Automation\Selenium\_Selenium Server"

start call selenium
SET PATH=%PATH%;D:\_Work\Automation\Selenium\_php5.6.14;
cd ../
cls

selenium is a call to a batch file to start up selenium server but for this isn't important, the important part is SET PATH=%PATH%;D:\_Work\Automation\Selenium\_php5.6.14; which i use so i can just use php or phpunit in Command Prompt from any folder

inside my php folder i have a phpunit.cmd file with the following line

@php "%~dp0phpunit.phar" %* 

now from Command Prompt if i call php TrelloInt.main.php i get my var_dump, likewise if i used phpunit TrelloInt.main.php with the exception it complains that there is no TrelloInt.main class (expected)

however i can call my php file with phpunit trelloint.main and it'll work fine but when i call my file with php trelloint.main it says it can't open but it'll work just fine when i add .php at the end.

Is there a way for me to get php to ignore the extension at the end like how PHPUnit does in Windows Command Prompt

  • 写回答

1条回答 默认 最新

  • dongmei2957 2016-08-24 23:42
    关注

    This has nothing to do with Windows' command prompt, and nothing to do with ignoring extensions.

    The PHP interpreter and PHPUnit simply expect different arguments:

    As far as I know there is no way to invoke PHP code by class using the php binary, and a look at its options doesn't reveal any way to do this.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教