【问题标题】:php -f file.php cats file to command line?php -f file.php 猫文件到命令行?
【发布时间】:2014-08-08 16:51:14
【问题描述】:

我刚刚写了一个简单的php文件,只包含:

echo 'some text';

我现在想从命令行执行它。当我做php -v 时,我得到:

HP 5.5.12-1~dotdeb.1 (cli) (built: May  6 2014 03:56:10)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans

但是当我执行php -f file.php 时,它只是简单地收集文件:

# php -f file.php
echo 'some text';
#

我也试过php file.php,但无济于事。

有人知道我在这里做错了什么吗?欢迎所有提示!

【问题讨论】:

  • 您可能被否决了,因为您没有包含 file.php 的内容,所以这不是一个合适的问题...

标签: php command-line command-line-interface


【解决方案1】:

只需在 file.php 中添加开始和结束标签 <?php ... ?> 即可。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-14
    • 2015-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多