diff --git a/php/example_code/s3/GettingStartedWithS3.php b/php/example_code/s3/GettingStartedWithS3.php index 51e37e3a510..f583e680167 100644 --- a/php/example_code/s3/GettingStartedWithS3.php +++ b/php/example_code/s3/GettingStartedWithS3.php @@ -148,7 +148,7 @@ public function runExample() $check = $this->s3client->listObjectsV2([ 'Bucket' => $this->bucketName, ]); - if (count($check) <= 0) { + if (isset($check['Contents']) && count($check['Contents']) > 0) { throw new Exception("Bucket wasn't empty."); } echo "Deleted all objects and folders from $this->bucketName.\n";