Php 确定属性值是否为空字符串
因此,我的方法中有以下Php 确定属性值是否为空字符串,php,Php,因此,我的方法中有以下foreach,如下所示: foreach ($profiles as $profile) { $profile->load([ 'azure_picture' => Azure::init()->set_blob_sas_url ($profile->get_employee_id()), 'azure_picture_expiration' => $profil
foreach
,如下所示:
foreach ($profiles as $profile) {
$profile->load([
'azure_picture' => Azure::init()->set_blob_sas_url
($profile->get_employee_id()),
'azure_picture_expiration' =>
$profile->set_azure_picture_expiration
(strtotime('+7 days')),
]);
$profile->save();
}
因此'azure\u picture'=>azure::init()->set\u blob\u sas\u url($profile->get\u employee\u id()),如果值为空,
将返回一个字符串“”
是否有一种方法可以确定azure\u picture
是否为空字符串,以便在'azure\u picture\u expiration'=>$profile->set\u azure\u picture\u expiration(strotime('+7天'),
中传入空字符串
因此,如果azure\u图片
为空,我希望传递一个空字符串,而不是自动传递strotime('+7天')
,否则,使用strotime('+7天')
所有的帮助将不胜感激
foreach ($profiles as $profile) {
$azure_picture = Azure::init()->set_blob_sas_url
($profile->get_employee_id());
$profile->load([
'azure_picture' => $azure_picture,
'azure_picture_expiration' =>
$profile->set_azure_picture_expiration
($azure_picture != '' ? strtotime('+7 days') : ''),
]);
$profile->save();
}
这就是您的意思吗?首先将图片放在变量中,以便只调用该方法一次。然后在过期时用一个简单的三元组进行跟进谢谢@netyro,我将尝试这个并跟进。