Closed phpstudyone closed 7 years ago
I have translated through Google Translate, so I hope that I understand correctly.
In this code, if the setOrderDescending
parameter is set to "false", the order will be ascending by "id". If the setOrderDescending
parameter is set to true, then the order will be descending by "id".
If you don't send either setOrderBy
or setOrderDescending
, the default behavior would be to return the results in ascending order by "id"
"false"
typeof is string .
false
typeof is bool .
identify $sorting->setOrderDescending("false");
with $sorting->setOrderDescending(true);
we can use
$sorting->setOrderDescending(false);
rather than
$sorting->setOrderDescending("false");
Ah, I think I understand.
If you put the value as "false", during the serialization process, it's turned to "true". That's because the serializer knows it should be boolean, and in PHP, any string that's not "0" is considered to be true: https://stackoverflow.com/questions/2382490/how-does-true-false-work-in-php
I committed a fix to the sample code to show the value as (false) instead of ("false"), which works correctly.
Thanks for the notification.
在
RecurringBilling/get-list-of-subscriptions.php
文件中,使用了如下代码:但是实际上
setOrderDescending
接受的参数应该为true
或者false
;看意图是不进行倒序排列,但是如果传递
"false"
参数是为true
的,是倒序排列的,这会带来困惑。