Phing 字符串操作

标签 phing

我有一个您传入参数的 Phing 项目。我想对这个参数执行简单的字符串操作,例如 strtolower() 或 ucwords() 等。有什么想法可以解决这个问题吗?

最佳答案

如何使用 PhpEvaLTask:

<project name="StringTest" default="all" basedir=".">
<target name="stringtest"  description="test">
    <php expression="strtolower(${param})" returnProperty="paramToLower"/>
    <php expression="ucwords(${param})" returnProperty="paramUcwords"/>
    <echo>To lower ${paramToLower}</echo>
    <echo>UcWords ${paramUcwords}</echo>
</target>

运行它:
phing -Dparam=BLAH stringtest

产量:
Buildfile: /export/users/marcelog/build.xml

字符串测试 > 字符串测试:
  [php] Evaluating PHP expression: strtolower(BLAH)
  [php] Evaluating PHP expression: ucwords(BLAH)
 [echo] To lower blah
 [echo] UcWords BLAH

build 完成

关于Phing 字符串操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10432771/

相关文章:

php - 为什么我的单元测试通过 Hudson/Phing 失败,但通过命令行上的 Phing 成功?

github - Phing - 从 Github 存储库中提取

php - 从项目目录加载自定义 Phing 任务

php - 在 Windows 和 Linux 上运行单元测试

phpunit - 如果代码覆盖率报告百分比较小,构建应该会失败

php - 如何正确部署您的 PHP 应用程序?

php - Symfony - 使用命令运行 Phing 任务

git - 自动 Phing 部署 - Git 询问密码

svn - 检查 SVN/subversion 中是否存在某个修订版(或标签)

PHP:在 Composer 包中使用 Phing 任务