本文整理匯總了PHP中Variable::setName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Variable::setName方法的具體用法?PHP Variable::setName怎麽用?PHP Variable::setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Variable
的用法示例。
在下文中一共展示了Variable::setName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parse
/**
* Parse a variable line
*
* @param string $varLine
* @return Variable
*/
public static function parse($varLine)
{
$parts = explode('=', $varLine, 2);
if (!$parts || count($parts) !== 2) {
throw new \InvalidArgumentException("Line does not appear to contain a variable");
}
$variable = new Variable();
$variable->setName(trim(array_shift($parts)))->setValue(trim(array_shift($parts)));
return $variable;
}
示例2: setVariable
public function setVariable()
{
try {
if (fRequest::get('remove', 'boolean')) {
$variable = new Variable(fRequest::get('name'));
$variable->delete();
fMessaging::create('success', 'Variable removed successfully.');
} else {
try {
$variable = new Variable(fRequest::get('name'));
} catch (fNotFoundException $e) {
$variable = new Variable();
$variable->setName(fRequest::get('name'));
}
$variable->setValue(fRequest::get('value'));
$variable->store();
fMessaging::create('success', 'Variable set successfully.');
}
} catch (fException $e) {
fMessaging::create('error', $e->getMessage());
}
fURL::redirect(Util::getReferer());
}