我有一个 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
Yields:
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
构建完成
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)