企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# C.111 Variable DESCRIPTION OF TASK. The Variable task provides a mutable property to Phing and works much like variable assignment in PHP. This task is similar to the standard Phing Property task, except that THESE PROPERTIES ARE MUTABLE. While this goes against the standard Phing use of properties, occasionally it is useful to be able to change a property value within the build. In general, use of this task is DISCOURAGED, and the standard Phing Property should be used if possible. Having said that, in real life I use this a lot. Variables can be set individually or loaded from a standard properties file. A 'feature' of variables is that they can override properties, but properties cannot override variables. So if an already established property exists, its value can be reassigned by use of this task. Table C.145:聽Attributes NameTypeDescriptionDefaultRequired`name``String`The name of the property to set.NoneYes, unless 'file' is used.`value``String`The value of the property.""No`unset``Boolean`Removes the property from the project as if it had never been set.falseNo`file``String`The name of a standard properties file to load variables from.NoneNo C.111.1 Example ``` <var name="x" value="6"/> <echo>x = ${x}</echo> <!-- print: 6 --> <var name="x" value="12"/> <echo>x = ${x}</echo> <!-- print: 12 --> <var name="x" value="6 + ${x}"/> <echo>x = ${x}</echo> <!-- print: 6 + 12 --> <var name="str" value="I "/> <var name="str" value="${str} am "/> <var name="str" value="${str} a "/> <var name="str" value="${str} string."/> <echo>${str}</echo> <!-- print: I am a string. --> <var name="x" value="6"/> <echo>x = ${x}</echo> <!-- print: 6 --> <property name="x" value="12"/> <echo>x = ${x}</echo> <!-- print: 6 (property can't override) --> <var name="x" value="blue"/> <tstamp> <format property="x" pattern="%A"/> </tstamp> <echo>Today is ${x}.</echo> <!-- print: Today is blue. --> <var name="x" value="" unset="true"/> <tstamp> <format property="x" pattern="%A"/> </tstamp> <echo>Today is ${x}.</echo> <!-- print: Today is Friday. --> ```