如果這個變量被動態地設定爲$ newsales_countday = 10以下命令將更新後的元鍵sales_countday,並給它的「10」如何1值添加到一個update_post_meta功能
update_post_meta ($productId, 'sales_countday', $newsales_countday) ;
的值
我想知道的是,你怎麼才能+1值,以便它可以是11。
我不擅長PHP的,所以我試圖說
$addone = 1 ;
然後
update_post_meta ($productId, 'sales_countday', $newsales_countday + $addone) ;
但我覺得我做錯了什麼。
我們通常希望用戶首先查閱手冊。如果你看到downvotes和關閉,沒有冒犯,就是這樣。進行簡單的數學運算通常在編程語言內部是可用的,所以我們希望用戶在參考文獻中查看,例如下一次您想知道如何減去一個數據然後。你明白? – hakre
http://php.net/language.operators.arithmetic - http://php.net/language.operators.increment - 缺少的鏈接,因爲它似乎即使是那些回答不給你的是哪種是一個恥辱,並不是一個新的用戶非常歡迎。 – hakre