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.

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

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决