[英]php array code working on localhost but not working on the server
The array is working fine on local machine and loops through the images but it fails to work on the aws server.该阵列在本地机器上工作正常并循环通过图像,但它无法在 aws 服务器上工作。 It says "Trying to access array offset on value of type null".
它说“尝试访问 null 类型值的数组偏移量”。
<?php
$image1 = get_field('add_image');
$image2 = get_field('add_image2');
$image3 = get_field('add_image3');
$images = array($image1, $image2, $image3);
?>
<?php $count = 0; ?>
<?php foreach($images as $value): ?>
<img src="<?php echo esc_url($value['url']); ?>" class="d-block w-100 wrap-image-single responsive " alt="..."> </a>
<?php $count++; endforeach; ?>
You may wish to try some basic debug...您可能希望尝试一些基本的调试...
var_dump($image1)
var_dump($image1)
$images
array and see what you have.$images
数组,看看你有什么。 Do you in fact have the 'url' key on each sub-array?This might be a minor issue.这可能是一个小问题。 Here is my process of debugging the issue:
这是我调试问题的过程:
add_image2, add_images3
for the function get_field
add_image2, add_images3
get_field
These are my two cents.这是我的两分钱。 Let me know how it goes.. :)
让我知道事情的后续.. :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.