我的 PHP 变量存在问题,并将它们设置为正确的值。基本上我有一种方法可以查看您是否存在商店以及该商店是否有姐妹商店。然后,我查看该存储是否作为文件系统中的图像,如果它没有显示并等待图像图像。
我的问题是,如果商店有姐妹店,那么它只会显示姐妹店的形象,因为姐妹店和主店都是我的代码
if(isset($storelocation)) {
//var_dump($sofalocation);
$path = $_SERVER{'DOCUMENT_ROOT'}.'/webroot/images/stores/'.strtolower(str_replace(' ', '-', $storelocation['storename'])).'.jpg';
if(file_exists($path)) {
//echo $path;
$this->assign('storeimage', 'images/stores/'.strtolower(str_replace(' ', '-', $storelocation['storename'])).'.jpg');
//var_dump($sofalocation['storename']);
} else {
echo $path;
$this->assign('storeimage', 'images/stores/awaiting-image.jpg');
}
}
if(isset($sisterlocation)) {
$path = $_SERVER{'DOCUMENT_ROOT'}.'/webroot/images/stores/'.strtolower(str_replace(' ', '-', $sisterlocation['storename'])).'.jpg';
if(file_exists($path)) {
$this->assign('sisterimage', 'images/stores/'.strtolower(str_replace(' ', '-', $sisterglocation['storename'])).'.jpg');
} else {
echo $path;
$this->assign('sisterimage', 'images/stores/awaiting-image.jpg');
// var_dump($sisterlocation['storename']);
}
}
奇怪的是,除非我在 isset 之前回显 var,否则 storelocation isset 似乎失败了,有什么想法吗?