【发布时间】:2013-10-02 04:22:31
【问题描述】:
如果此变量动态设置为 $newsales_countday = 10。下面的命令将更新后元键 sales_countday,并赋予其值为 '10'
update_post_meta ( $productId, 'sales_countday', $newsales_countday ) ;
我想知道的是,你怎么能只对该值 +1,以便它可以改为 11。
我不擅长php,所以我试着说
$addone = 1 ;
然后
update_post_meta ( $productId, 'sales_countday', $newsales_countday + $addone ) ;
但我认为我做错了什么。
【问题讨论】:
-
我们通常希望用户先查阅手册。如果您看到投票和关闭,请不要冒犯,仅此而已。进行简单的数学运算通常在编程语言中固有地可用,因此我们希望用户在参考中查找它,例如下次您想知道如何减去一个然后。你明白吗?
-
php.net/language.operators.arithmetic - php.net/language.operators.increment - 缺少的链接似乎即使是那些回答的人也不会告诉你哪种是一种耻辱并且对新用户不太欢迎。
标签: php string wordpress math integer